stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for 4.4.y, 4.9.y, 4.14.y, 4.19.y] net: cdc_ncm: Signedness bug in cdc_ncm_set_dgram_size()
@ 2019-11-20  3:07 Nobuhiro Iwamatsu
  2019-11-21 17:50 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Nobuhiro Iwamatsu @ 2019-11-20  3:07 UTC (permalink / raw)
  To: stable

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

commit a56dcc6b455830776899ce3686735f1172e12243 upstream.

This code is supposed to test for negative error codes and partial
reads, but because sizeof() is size_t (unsigned) type then negative
error codes are type promoted to high positive values and the condition
doesn't work as expected.

Fixes: 332f989a3b00 ("CDC-NCM: handle incomplete transfer of MTU")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
---
 drivers/net/usb/cdc_ncm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 71ef895b4dca..bab13ccfb085 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -534,7 +534,7 @@ static void cdc_ncm_set_dgram_size(struct usbnet *dev, int new_size)
 	err = usbnet_read_cmd(dev, USB_CDC_GET_MAX_DATAGRAM_SIZE,
 			      USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE,
 			      0, iface_no, &max_datagram_size, sizeof(max_datagram_size));
-	if (err < sizeof(max_datagram_size)) {
+	if (err != sizeof(max_datagram_size)) {
 		dev_dbg(&dev->intf->dev, "GET_MAX_DATAGRAM_SIZE failed\n");
 		goto out;
 	}
-- 
2.23.0


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

* Re: [PATCH for 4.4.y, 4.9.y, 4.14.y, 4.19.y] net: cdc_ncm: Signedness bug in cdc_ncm_set_dgram_size()
  2019-11-20  3:07 [PATCH for 4.4.y, 4.9.y, 4.14.y, 4.19.y] net: cdc_ncm: Signedness bug in cdc_ncm_set_dgram_size() Nobuhiro Iwamatsu
@ 2019-11-21 17:50 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2019-11-21 17:50 UTC (permalink / raw)
  To: Nobuhiro Iwamatsu; +Cc: stable

On Wed, Nov 20, 2019 at 12:07:10PM +0900, Nobuhiro Iwamatsu wrote:
> From: Dan Carpenter <dan.carpenter@oracle.com>
> 
> commit a56dcc6b455830776899ce3686735f1172e12243 upstream.
> 
> This code is supposed to test for negative error codes and partial
> reads, but because sizeof() is size_t (unsigned) type then negative
> error codes are type promoted to high positive values and the condition
> doesn't work as expected.
> 
> Fixes: 332f989a3b00 ("CDC-NCM: handle incomplete transfer of MTU")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
> ---
>  drivers/net/usb/cdc_ncm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Now queud up, thanks!

greg k-h

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

end of thread, other threads:[~2019-11-21 17:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-20  3:07 [PATCH for 4.4.y, 4.9.y, 4.14.y, 4.19.y] net: cdc_ncm: Signedness bug in cdc_ncm_set_dgram_size() Nobuhiro Iwamatsu
2019-11-21 17:50 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).