diff mbox series

cx82310_eth: fix a memory leak bug

Message ID 1565805819-8113-1-git-send-email-wenwen@cs.uga.edu
State Accepted
Delegated to: David Miller
Headers show
Series cx82310_eth: fix a memory leak bug | expand

Commit Message

Wenwen Wang Aug. 14, 2019, 6:03 p.m. UTC
In cx82310_bind(), 'dev->partial_data' is allocated through kmalloc().
Then, the execution waits for the firmware to become ready. If the firmware
is not ready in time, the execution is terminated. However, the allocated
'dev->partial_data' is not deallocated on this path, leading to a memory
leak bug. To fix this issue, free 'dev->partial_data' before returning the
error.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
---
 drivers/net/usb/cx82310_eth.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

David Miller Aug. 18, 2019, 8:02 p.m. UTC | #1
From: Wenwen Wang <wenwen@cs.uga.edu>
Date: Wed, 14 Aug 2019 13:03:38 -0500

> In cx82310_bind(), 'dev->partial_data' is allocated through kmalloc().
> Then, the execution waits for the firmware to become ready. If the firmware
> is not ready in time, the execution is terminated. However, the allocated
> 'dev->partial_data' is not deallocated on this path, leading to a memory
> leak bug. To fix this issue, free 'dev->partial_data' before returning the
> error.
> 
> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>

Applied.
diff mbox series

Patch

diff --git a/drivers/net/usb/cx82310_eth.c b/drivers/net/usb/cx82310_eth.c
index 5519248..32b08b1 100644
--- a/drivers/net/usb/cx82310_eth.c
+++ b/drivers/net/usb/cx82310_eth.c
@@ -163,7 +163,8 @@  static int cx82310_bind(struct usbnet *dev, struct usb_interface *intf)
 	}
 	if (!timeout) {
 		dev_err(&udev->dev, "firmware not ready in time\n");
-		return -ETIMEDOUT;
+		ret = -ETIMEDOUT;
+		goto err;
 	}
 
 	/* enable ethernet mode (?) */