net: usb: lan78xx: drop redundant device reference
PATCH 1/1 net: usb: lan78xx: drop redundant device reference
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
--- drivers/net/usb/lan78xx.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/net/usb/lan78xx.c +1 -8
@@ -4530,7 +4530,6 @@ static void intr_complete(struct urb *urb)static void lan78xx_disconnect (struct usb_interface *intf) {struct lan78xx_net *dev; -struct usb_device *udev;struct net_device *net; dev =usb_get_intfdata (intf);
@@ -4538,7 +4537,6 @@ static void lan78xx_disconnect(struct usb_interface *intf)if (!dev)return ; - udev =interface_to_usbdev (intf); net = dev->net;rtnl_lock ();
@@ -4567,7 +4565,6 @@ static void lan78xx_disconnect(struct usb_interface *intf)usb_free_urb (dev->urb_intr);free_netdev (net); -usb_put_dev (udev); }static void lan78xx_tx_timeout (struct net_device *net,unsigned int txqueue)
@@ -4629,13 +4626,11 @@ static int lan78xx_probe(struct usb_interface *intf,u8 *buf =NULL ; udev =interface_to_usbdev (intf); - udev =usb_get_dev (udev); netdev =alloc_etherdev (sizeof (struct lan78xx_net ));if (!netdev) {dev_err (&intf->dev,"Error: OOM\n" ); - ret = -ENOMEM ; - goto out1; +return -ENOMEM ; }SET_NETDEV_DEV (netdev, &intf->dev);
@@ -4784,8 +4779,6 @@ static int lan78xx_probe(struct usb_interface *intf,lan78xx_free_tx_resources (dev); out2:free_netdev (netdev); -out1: -usb_put_dev (udev);return ret; }
Signature · 1 line
2.52.0
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Thu, 5 Mar 2026 11:50:06 +0100 you wrote:
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
[...]
Here is the summary with links:
- net: usb: lan78xx: drop redundant device reference
https://git.kernel.org/netdev/net-next/c/f4ac0cc88e99
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html