All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] net: cdc_ncm: fix typo in test for supported formats
@ 2014-05-22  7:52 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2014-05-22  7:52 UTC (permalink / raw)
  To: Oliver Neukum, Bjørn Mork; +Cc: netdev, kernel-janitors

There is a typo here where we test for USB_CDC_NCM_NTH32_SIGN instead
of USB_CDC_NCM_NTB32_SUPPORTED.  The test probably still works as
written because 0x686D636E has (1 << 1) set and doesn't have (1 << 0)
set.

Fixes: f8afb73da375 ('net: cdc_ncm: factor out one-time device initialization')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Static analysis.  Untested.  Applies on -next

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index ad2a386..93c9ca9 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -357,7 +357,8 @@ static int cdc_ncm_init(struct usbnet *dev)
 	 * "The host shall only send this command while the NCM Data
 	 *  Interface is in alternate setting 0."
 	 */
-	if (le16_to_cpu(ctx->ncm_parm.bmNtbFormatsSupported) & USB_CDC_NCM_NTH32_SIGN) {
+	if (le16_to_cpu(ctx->ncm_parm.bmNtbFormatsSupported) &
+						USB_CDC_NCM_NTB32_SUPPORTED) {
 		dev_dbg(&dev->intf->dev, "Setting NTB format to 16-bit\n");
 		err = usbnet_write_cmd(dev, USB_CDC_SET_NTB_FORMAT,
 				       USB_TYPE_CLASS | USB_DIR_OUT

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [patch] net: cdc_ncm: fix typo in test for supported formats
@ 2014-05-22  7:52 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2014-05-22  7:52 UTC (permalink / raw)
  To: Oliver Neukum, Bjørn Mork; +Cc: netdev, kernel-janitors

There is a typo here where we test for USB_CDC_NCM_NTH32_SIGN instead
of USB_CDC_NCM_NTB32_SUPPORTED.  The test probably still works as
written because 0x686D636E has (1 << 1) set and doesn't have (1 << 0)
set.

Fixes: f8afb73da375 ('net: cdc_ncm: factor out one-time device initialization')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Static analysis.  Untested.  Applies on -next

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index ad2a386..93c9ca9 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -357,7 +357,8 @@ static int cdc_ncm_init(struct usbnet *dev)
 	 * "The host shall only send this command while the NCM Data
 	 *  Interface is in alternate setting 0."
 	 */
-	if (le16_to_cpu(ctx->ncm_parm.bmNtbFormatsSupported) & USB_CDC_NCM_NTH32_SIGN) {
+	if (le16_to_cpu(ctx->ncm_parm.bmNtbFormatsSupported) &
+						USB_CDC_NCM_NTB32_SUPPORTED) {
 		dev_dbg(&dev->intf->dev, "Setting NTB format to 16-bit\n");
 		err = usbnet_write_cmd(dev, USB_CDC_SET_NTB_FORMAT,
 				       USB_TYPE_CLASS | USB_DIR_OUT

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [patch] net: cdc_ncm: fix typo in test for supported formats
  2014-05-22  7:52 ` Dan Carpenter
@ 2014-05-22  8:27   ` Bjørn Mork
  -1 siblings, 0 replies; 6+ messages in thread
From: Bjørn Mork @ 2014-05-22  8:27 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Oliver Neukum, netdev, kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> writes:

> There is a typo here where we test for USB_CDC_NCM_NTH32_SIGN instead
> of USB_CDC_NCM_NTB32_SUPPORTED.  The test probably still works as
> written because 0x686D636E has (1 << 1) set and doesn't have (1 << 0)
> set.
>
> Fixes: f8afb73da375 ('net: cdc_ncm: factor out one-time device initialization')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Static analysis.  Untested.  Applies on -next
>
> diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
> index ad2a386..93c9ca9 100644
> --- a/drivers/net/usb/cdc_ncm.c
> +++ b/drivers/net/usb/cdc_ncm.c
> @@ -357,7 +357,8 @@ static int cdc_ncm_init(struct usbnet *dev)
>  	 * "The host shall only send this command while the NCM Data
>  	 *  Interface is in alternate setting 0."
>  	 */
> -	if (le16_to_cpu(ctx->ncm_parm.bmNtbFormatsSupported) & USB_CDC_NCM_NTH32_SIGN) {
> +	if (le16_to_cpu(ctx->ncm_parm.bmNtbFormatsSupported) &
> +						USB_CDC_NCM_NTB32_SUPPORTED) {
>  		dev_dbg(&dev->intf->dev, "Setting NTB format to 16-bit\n");
>  		err = usbnet_write_cmd(dev, USB_CDC_SET_NTB_FORMAT,
>  				       USB_TYPE_CLASS | USB_DIR_OUT


Thanks!  Yes, that is correct.

I actually thought I had fixed that bug a while ago, but instead I
managed to just copy it while refactoring.  Impressive...


It doesn't matter whether (1 << 0) is set.  In fact it always will be.
What makes this work despite the bug is that no other bits will ever be
set - they are all reserved and must be zero.  But the spec also
requires us to ignore them, so your fix is definitely needed.


Bjørn

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] net: cdc_ncm: fix typo in test for supported formats
@ 2014-05-22  8:27   ` Bjørn Mork
  0 siblings, 0 replies; 6+ messages in thread
From: Bjørn Mork @ 2014-05-22  8:27 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Oliver Neukum, netdev, kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> writes:

> There is a typo here where we test for USB_CDC_NCM_NTH32_SIGN instead
> of USB_CDC_NCM_NTB32_SUPPORTED.  The test probably still works as
> written because 0x686D636E has (1 << 1) set and doesn't have (1 << 0)
> set.
>
> Fixes: f8afb73da375 ('net: cdc_ncm: factor out one-time device initialization')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Static analysis.  Untested.  Applies on -next
>
> diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
> index ad2a386..93c9ca9 100644
> --- a/drivers/net/usb/cdc_ncm.c
> +++ b/drivers/net/usb/cdc_ncm.c
> @@ -357,7 +357,8 @@ static int cdc_ncm_init(struct usbnet *dev)
>  	 * "The host shall only send this command while the NCM Data
>  	 *  Interface is in alternate setting 0."
>  	 */
> -	if (le16_to_cpu(ctx->ncm_parm.bmNtbFormatsSupported) & USB_CDC_NCM_NTH32_SIGN) {
> +	if (le16_to_cpu(ctx->ncm_parm.bmNtbFormatsSupported) &
> +						USB_CDC_NCM_NTB32_SUPPORTED) {
>  		dev_dbg(&dev->intf->dev, "Setting NTB format to 16-bit\n");
>  		err = usbnet_write_cmd(dev, USB_CDC_SET_NTB_FORMAT,
>  				       USB_TYPE_CLASS | USB_DIR_OUT


Thanks!  Yes, that is correct.

I actually thought I had fixed that bug a while ago, but instead I
managed to just copy it while refactoring.  Impressive...


It doesn't matter whether (1 << 0) is set.  In fact it always will be.
What makes this work despite the bug is that no other bits will ever be
set - they are all reserved and must be zero.  But the spec also
requires us to ignore them, so your fix is definitely needed.


Bjørn
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] net: cdc_ncm: fix typo in test for supported formats
  2014-05-22  7:52 ` Dan Carpenter
@ 2014-05-22 19:53   ` David Miller
  -1 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2014-05-22 19:53 UTC (permalink / raw)
  To: dan.carpenter; +Cc: oliver, bjorn, netdev, kernel-janitors

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Thu, 22 May 2014 10:52:29 +0300

> There is a typo here where we test for USB_CDC_NCM_NTH32_SIGN instead
> of USB_CDC_NCM_NTB32_SUPPORTED.  The test probably still works as
> written because 0x686D636E has (1 << 1) set and doesn't have (1 << 0)
> set.
> 
> Fixes: f8afb73da375 ('net: cdc_ncm: factor out one-time device initialization')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied to net-next, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] net: cdc_ncm: fix typo in test for supported formats
@ 2014-05-22 19:53   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2014-05-22 19:53 UTC (permalink / raw)
  To: dan.carpenter; +Cc: oliver, bjorn, netdev, kernel-janitors

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Thu, 22 May 2014 10:52:29 +0300

> There is a typo here where we test for USB_CDC_NCM_NTH32_SIGN instead
> of USB_CDC_NCM_NTB32_SUPPORTED.  The test probably still works as
> written because 0x686D636E has (1 << 1) set and doesn't have (1 << 0)
> set.
> 
> Fixes: f8afb73da375 ('net: cdc_ncm: factor out one-time device initialization')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied to net-next, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-05-22 19:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-22  7:52 [patch] net: cdc_ncm: fix typo in test for supported formats Dan Carpenter
2014-05-22  7:52 ` Dan Carpenter
2014-05-22  8:27 ` Bjørn Mork
2014-05-22  8:27   ` Bjørn Mork
2014-05-22 19:53 ` David Miller
2014-05-22 19:53   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.