Skip to content

Commit 6314dab

Browse files
bmorkdavem330
authored andcommitted
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 <[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]>
1 parent b74912a commit 6314dab

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/usb/cdc_ncm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
771771
int err;
772772
u8 iface_no;
773773
struct usb_cdc_parsed_header hdr;
774-
u16 curr_ntb_format;
774+
__le16 curr_ntb_format;
775775

776776
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
777777
if (!ctx)
@@ -889,7 +889,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
889889
goto error2;
890890
}
891891

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

0 commit comments

Comments
 (0)