Commit 9ea1fead authored by Wenwen Wang's avatar Wenwen Wang Committed by Greg Kroah-Hartman

lan78xx: Fix memory leaks

[ Upstream commit b9cbf8a6 ]

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: default avatarWenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 375ab446
...@@ -3799,7 +3799,7 @@ static int lan78xx_probe(struct usb_interface *intf, ...@@ -3799,7 +3799,7 @@ static int lan78xx_probe(struct usb_interface *intf,
ret = register_netdev(netdev); ret = register_netdev(netdev);
if (ret != 0) { if (ret != 0) {
netif_err(dev, probe, netdev, "couldn't register the device\n"); netif_err(dev, probe, netdev, "couldn't register the device\n");
goto out3; goto out4;
} }
usb_set_intfdata(intf, dev); usb_set_intfdata(intf, dev);
...@@ -3814,12 +3814,14 @@ static int lan78xx_probe(struct usb_interface *intf, ...@@ -3814,12 +3814,14 @@ static int lan78xx_probe(struct usb_interface *intf,
ret = lan78xx_phy_init(dev); ret = lan78xx_phy_init(dev);
if (ret < 0) if (ret < 0)
goto out4; goto out5;
return 0; return 0;
out4: out5:
unregister_netdev(netdev); unregister_netdev(netdev);
out4:
usb_free_urb(dev->urb_intr);
out3: out3:
lan78xx_unbind(dev, intf); lan78xx_unbind(dev, intf);
out2: out2:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment