aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2017-11-15 03:35:02 -0500
committerDavid S. Miller <davem@davemloft.net>2017-11-15 05:43:54 -0500
commit6314dab4b8fb8493d810e175cb340376052c69b6 (patch)
tree0df41369825588fd52ceb906f44cdc64fca90190
parentb74912a2fdae9aadd20da502644aa8848c861954 (diff)
net: cdc_ncm: GetNtbFormat endian fix
The GetNtbFormat and SetNtbFormat requests operate on 16 bit little endian values. We get away with ignoring this most of the time, because we only care about USB_CDC_NCM_NTB16_FORMAT which is 0x0000. This fails for USB_CDC_NCM_NTB32_FORMAT. Fix comparison between LE value from device and constant by converting the constant to LE. Reported-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Fixes: 2b02c20ce0c2 ("cdc_ncm: Set NTB format again after altsetting switch for Huawei devices") Cc: Enrico Mioso <mrkiko.rs@gmail.com> Cc: Christian Panton <christian@panton.org> Signed-off-by: Bjørn Mork <bjorn@mork.no> Acked-By: Enrico Mioso <mrkiko.rs@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/usb/cdc_ncm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 47cab1bde065..9e1b74590682 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -771,7 +771,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
771 int err; 771 int err;
772 u8 iface_no; 772 u8 iface_no;
773 struct usb_cdc_parsed_header hdr; 773 struct usb_cdc_parsed_header hdr;
774 u16 curr_ntb_format; 774 __le16 curr_ntb_format;
775 775
776 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 776 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
777 if (!ctx) 777 if (!ctx)
@@ -889,7 +889,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
889 goto error2; 889 goto error2;
890 } 890 }
891 891
892 if (curr_ntb_format == USB_CDC_NCM_NTB32_FORMAT) { 892 if (curr_ntb_format == cpu_to_le16(USB_CDC_NCM_NTB32_FORMAT)) {
893 dev_info(&intf->dev, "resetting NTB format to 16-bit"); 893 dev_info(&intf->dev, "resetting NTB format to 16-bit");
894 err = usbnet_write_cmd(dev, USB_CDC_SET_NTB_FORMAT, 894 err = usbnet_write_cmd(dev, USB_CDC_SET_NTB_FORMAT,
895 USB_TYPE_CLASS | USB_DIR_OUT 895 USB_TYPE_CLASS | USB_DIR_OUT