lan78xx: Fix memory leaks [Linux 4.19.72]

This Linux kernel change "lan78xx: Fix memory leaks" is included in the Linux 4.19.72 release. This change is authored by Wenwen Wang <wenwen [at]> on Wed Aug 14 11:23:13 2019 -0500. The commit for this change in Linux stable tree is 9ea1fea (patch) which is from upstream commit b9cbf8a. 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 b9cbf8a.

lan78xx: Fix memory leaks

[ Upstream commit b9cbf8a64865b50fd0f4a3915fa00ac7365cdf8f ]

In lan78xx_probe(), a new urb is allocated through usb_alloc_urb() and
saved to 'dev->urb_intr'. However, in the following execution, if an error
occurs, 'dev->urb_intr' is not deallocated, leading to memory leaks. To fix
this issue, invoke usb_free_urb() to free the allocated urb before
returning from the function.

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

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

 drivers/net/usb/lan78xx.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 8d14049..e20266b 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -3799,7 +3799,7 @@ static int lan78xx_probe(struct usb_interface *intf,
    ret = register_netdev(netdev);
    if (ret != 0) {
        netif_err(dev, probe, netdev, "couldn't register the device\n");
-       goto out3;
+       goto out4;

    usb_set_intfdata(intf, dev);
@@ -3814,12 +3814,14 @@ static int lan78xx_probe(struct usb_interface *intf,

    ret = lan78xx_phy_init(dev);
    if (ret < 0)
-       goto out4;
+       goto out5;

    return 0;

+   usb_free_urb(dev->urb_intr);
    lan78xx_unbind(dev, intf);

Leave a Reply

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