cx82310_eth: fix a memory leak bug [Linux 4.4.192]

This Linux kernel change "cx82310_eth: fix a memory leak bug" is included in the Linux 4.4.192 release. This change is authored by Wenwen Wang <wenwen [at]> on Wed Aug 14 13:03:38 2019 -0500. The commit for this change in Linux stable tree is 2d28afe (patch) which is from upstream commit 1eca92e. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 1eca92e.

cx82310_eth: fix a memory leak bug

[ Upstream commit 1eca92eef18719027d394bf1a2d276f43e7cf886 ]

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

Signed-off-by: Wenwen Wang <>
Signed-off-by: David S. Miller <>
Signed-off-by: Sasha Levin <>

There are 3 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 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 947bea8..dfbdea2 100644
--- a/drivers/net/usb/cx82310_eth.c
+++ b/drivers/net/usb/cx82310_eth.c
@@ -175,7 +175,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 (?) */

Leave a Reply

Your email address will not be published. Required fields are marked *