Skip to content

Commit

Permalink
net: cdc_ncm: GetNtbFormat endian fix
Browse files Browse the repository at this point in the history
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 <[email protected]>
Fixes: 2b02c20 ("cdc_ncm: Set NTB format again after altsetting switch for Huawei devices")
Cc: Enrico Mioso <[email protected]>
Cc: Christian Panton <[email protected]>
Signed-off-by: Bjørn Mork <[email protected]>
Acked-By: Enrico Mioso <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
bmork authored and davem330 committed Nov 15, 2017
1 parent b74912a commit 6314dab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/usb/cdc_ncm.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
int err;
u8 iface_no;
struct usb_cdc_parsed_header hdr;
u16 curr_ntb_format;
__le16 curr_ntb_format;

ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
if (!ctx)
Expand Down Expand Up @@ -889,7 +889,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
goto error2;
}

if (curr_ntb_format == USB_CDC_NCM_NTB32_FORMAT) {
if (curr_ntb_format == cpu_to_le16(USB_CDC_NCM_NTB32_FORMAT)) {
dev_info(&intf->dev, "resetting NTB format to 16-bit");
err = usbnet_write_cmd(dev, USB_CDC_SET_NTB_FORMAT,
USB_TYPE_CLASS | USB_DIR_OUT
Expand Down

0 comments on commit 6314dab

Please sign in to comment.