Message ID | 20171115083502.3114-1-bjorn@mork.no |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
Series | [net,stable] net: cdc_ncm: GetNtbFormat endian fix | expand |
Thank you very much Ben and bjorn, for the spot, the fix, and overall helping me learn new things. Acked-By: Enrico Mioso <mrkiko.rs@gmail.com> On Wed, 15 Nov 2017, Bjørn Mork wrote: > Date: Wed, 15 Nov 2017 09:35:02 > From: Bjørn Mork <bjorn@mork.no> > To: netdev@vger.kernel.org > Cc: Oliver Neukum <oliver@neukum.org>, > Ben Hutchings <ben.hutchings@codethink.co.uk>, linux-usb@vger.kernel.org, > Bjørn Mork <bjorn@mork.no>, Enrico Mioso <mrkiko.rs@gmail.com>, > Christian Panton <christian@panton.org> > Subject: [PATCH net,stable] 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> > --- > drivers/net/usb/cdc_ncm.c | 4 ++-- > 1 file 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_ > 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) > @@ -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 > -- > 2.11.0 > >
From: Bjørn Mork <bjorn@mork.no> Date: Wed, 15 Nov 2017 09:35:02 +0100 > 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> Applied and queued up for -stable, thanks.
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_ 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) @@ -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
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> --- drivers/net/usb/cdc_ncm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)