[net] net: cdc_ncm: Signedness bug in cdc_ncm_set_dgram_size()
diff mbox series

Message ID 20191113182831.yjbmhwacirh6kgzr@kili.mountain
State Accepted
Delegated to: David Miller
Headers show
Series
  • [net] net: cdc_ncm: Signedness bug in cdc_ncm_set_dgram_size()
Related show

Commit Message

Dan Carpenter Nov. 13, 2019, 6:28 p.m. UTC
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>
---
 drivers/net/usb/cdc_ncm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Miller Nov. 13, 2019, 10:38 p.m. UTC | #1
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Wed, 13 Nov 2019 21:28:31 +0300

> 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>

Applied.

Patch
diff mbox series

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index a245597a3902..c2c82e6391b4 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -579,7 +579,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;
 	}