Skip to contentSkip to conversation

Staging: gdm72xx: make "len" unsigned

PATCH New Dan Carpenter 2 participants 2 messages Feb 22, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/6 Staging: gdm72xx: make "len" unsigned

We had an underflow bug here and I think I fixed it but we may as well be proactive and make "len" unsigned to be double sure.

drivers/staging/gdm72xx/gdm_wimax.h +2 -2
index 3330cd79..ed12813 100644
@@ -26,10 +26,10 @@
 struct phy_dev {
 	void			*priv_dev;
 	struct net_device	*netdev;
-	int (*send_func)(void *priv_dev, void *data, int len,
+	int (*send_func)(void *priv_dev, void *data, size_t len,
 			 void (*cb)(void *cb_data), void *cb_data);
 	int (*rcv_func)(void *priv_dev,
-			void (*cb)(void *cb_data, void *data, int len),
+			void (*cb)(void *cb_data, void *data, size_t len),
 			void *cb_data);
 };
 
drivers/staging/gdm72xx/gdm_usb.h +1 -1
index d864928..1456da0 100644
@@ -49,7 +49,7 @@ struct usb_rx {
 	struct rx_cxt		*rx_cxt;
 	struct urb		*urb;
 	u8			*buf;
-	void (*callback)(void *cb_data, void *data, int len);
+	void (*callback)(void *cb_data, void *data, size_t len);
 	void *cb_data;
 };
 
drivers/staging/gdm72xx/gdm_usb.c +3 -3
index 7f035b1..bbf3e70 100644
@@ -284,7 +284,7 @@ static void gdm_usb_send_complete(struct urb *urb)
 	spin_unlock_irqrestore(&tx->lock, flags);
 }
 
-static int gdm_usb_send(void *priv_dev, void *data, int len,
+static int gdm_usb_send(void *priv_dev, void *data, size_t len,
 			void (*cb)(void *data), void *cb_data)
 {
 	struct usbwm_dev *udev = priv_dev;
@@ -341,7 +341,7 @@ static int gdm_usb_send(void *priv_dev, void *data, int len,
 	usb_fill_bulk_urb(t->urb, usbdev, usb_sndbulkpipe(usbdev, 1), t->buf,
 			  len + padding, gdm_usb_send_complete, t);
 
-	dev_dbg(&usbdev->dev, "usb_send: %*ph\n", len + padding, t->buf);
+	dev_dbg(&usbdev->dev, "usb_send: %*ph\n", (int)len + padding, t->buf);
 
 #ifdef CONFIG_WIMAX_GDM72XX_USB_PM
 	if (usbdev->state & USB_STATE_SUSPENDED) {
@@ -460,7 +460,7 @@ static void gdm_usb_rcv_complete(struct urb *urb)
 }
 
 static int gdm_usb_receive(void *priv_dev,
-			   void (*cb)(void *cb_data, void *data, int len),
+			   void (*cb)(void *cb_data, void *data, size_t len),
 			   void *cb_data)
 {
 	struct usbwm_dev *udev = priv_dev;
drivers/staging/gdm72xx/gdm_wimax.c +2 -2
index 1b3da2b..6d647d6 100644
@@ -701,7 +701,7 @@ static void gdm_wimax_transmit_pkt(struct net_device *dev, char *buf, int len)
 	}
 }
 
-static void rx_complete(void *arg, void *data, int len)
+static void rx_complete(void *arg, void *data, size_t len)
 {
 	struct nic *nic = arg;
 
@@ -709,7 +709,7 @@ static void rx_complete(void *arg, void *data, int len)
 	gdm_wimax_rcv_with_cb(nic, rx_complete, nic);
 }
 
-static void prepare_rx_complete(void *arg, void *data, int len)
+static void prepare_rx_complete(void *arg, void *data, size_t len)
 {
 	struct nic *nic = arg;
 	int ret;
#1 lore raw
reproduce:

Hi Dan,

[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v4.5-rc5 next-20160222]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Dan-Carpenter/staging-gdm72xx-underflow-in-netlink_rcv_cb/20160223-033632
config: i386-randconfig-a0-02220022 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

drivers/staging/gdm72xx/gdm_sdio.c: In function 'sdio_wimax_probe':

>> drivers/staging/gdm72xx/gdm_sdio.c:628:21: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
     phy_dev->send_func = gdm_sdio_send;
                        ^
   drivers/staging/gdm72xx/gdm_sdio.c:629:20: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
     phy_dev->rcv_func = gdm_sdio_receive;
                       ^

vim +628 drivers/staging/gdm72xx/gdm_sdio.c

247e9cff Sage Ahn        2012-05-15  612  	ret = sdio_boot(func);
247e9cff Sage Ahn        2012-05-15  613  	if (ret)
247e9cff Sage Ahn        2012-05-15  614  		return ret;
247e9cff Sage Ahn        2012-05-15  615  
c2a1793d Devendra Naga   2012-07-12  616  	phy_dev = kzalloc(sizeof(*phy_dev), GFP_KERNEL);
c32bb25e Sudip Mukherjee 2015-09-07  617  	if (!phy_dev) {
247e9cff Sage Ahn        2012-05-15  618  		ret = -ENOMEM;
247e9cff Sage Ahn        2012-05-15  619  		goto out;
247e9cff Sage Ahn        2012-05-15  620  	}
c2a1793d Devendra Naga   2012-07-12  621  	sdev = kzalloc(sizeof(*sdev), GFP_KERNEL);
c32bb25e Sudip Mukherjee 2015-09-07  622  	if (!sdev) {
247e9cff Sage Ahn        2012-05-15  623  		ret = -ENOMEM;
247e9cff Sage Ahn        2012-05-15  624  		goto out;
247e9cff Sage Ahn        2012-05-15  625  	}
247e9cff Sage Ahn        2012-05-15  626  
247e9cff Sage Ahn        2012-05-15  627  	phy_dev->priv_dev = (void *)sdev;
247e9cff Sage Ahn        2012-05-15 @628  	phy_dev->send_func = gdm_sdio_send;
247e9cff Sage Ahn        2012-05-15  629  	phy_dev->rcv_func = gdm_sdio_receive;
247e9cff Sage Ahn        2012-05-15  630  
247e9cff Sage Ahn        2012-05-15  631  	ret = init_sdio(sdev);
f1efd9fe Alan Cox        2012-09-04  632  	if (ret < 0)
247e9cff Sage Ahn        2012-05-15  633  		goto out;
247e9cff Sage Ahn        2012-05-15  634  
247e9cff Sage Ahn        2012-05-15  635  	sdev->func = func;
247e9cff Sage Ahn        2012-05-15  636  

:::::: The code at line 628 was first introduced by commit
:::::: 247e9cffdce024fec5f55f76a8592f2fa8b3aa7b staging: gdm72xx: Add GCT GDM72xx WiMAX driver.

:::::: TO: Sage Ahn <[email protected]>
:::::: CC: Greg Kroah-Hartman <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation