* [PATCH] cx82310_eth: fix a memory leak bug
@ 2019-08-14 18:03 Wenwen Wang
2019-08-18 20:02 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Wenwen Wang @ 2019-08-14 18:03 UTC (permalink / raw)
To: Wenwen Wang
Cc: David S. Miller, Thomas Gleixner, Steve Winslow, Jilayne Lovejoy,
Kate Stewart, open list:USB NETWORKING DRIVERS,
open list:NETWORKING DRIVERS, open list
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(-)
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 (?) */
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cx82310_eth: fix a memory leak bug
2019-08-14 18:03 [PATCH] cx82310_eth: fix a memory leak bug Wenwen Wang
@ 2019-08-18 20:02 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-08-18 20:02 UTC (permalink / raw)
To: wenwen
Cc: tglx, swinslow, opensource, kstewart, linux-usb, netdev, linux-kernel
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-18 20:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14 18:03 [PATCH] cx82310_eth: fix a memory leak bug Wenwen Wang
2019-08-18 20:02 ` David Miller
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).