From: Xenia Ragiadakou Date: Mon, 9 Sep 2013 18:03:07 +0000 (+0300) Subject: xhci: fix incorrect type in assignment in xhci_count_num_dropped_endpoints() X-Git-Tag: next-20131204~13^2~29^2~5 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=78d1ff025698e1a70e3fef38342648d4dc826cf6;p=karo-tx-linux.git xhci: fix incorrect type in assignment in xhci_count_num_dropped_endpoints() The fields 'add_flags' and 'drop_flags' in struct xhci_input_control_ctx have type __le32 and need to be converted to CPU byteorder before being used to derive the number of dropped endpoints. This bug was found using sparse. This patch is not suitable for stable, since the bug would only be triggered on big endian systems, and the code only runs for Intel xHCI host controllers, which are always integrated into little endian systems. Signed-off-by: Xenia Ragiadakou Signed-off-by: Sarah Sharp --- diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index b7289e9a44dd..900ba36ee2b8 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1909,8 +1909,8 @@ static unsigned int xhci_count_num_dropped_endpoints(struct xhci_hcd *xhci, u32 valid_add_flags; u32 valid_drop_flags; - valid_add_flags = ctrl_ctx->add_flags >> 2; - valid_drop_flags = ctrl_ctx->drop_flags >> 2; + valid_add_flags = le32_to_cpu(ctrl_ctx->add_flags) >> 2; + valid_drop_flags = le32_to_cpu(ctrl_ctx->drop_flags) >> 2; return hweight32(valid_drop_flags) - hweight32(valid_add_flags & valid_drop_flags);