Skip to content

Commit ae7370e

Browse files
oleremkuba-moo
authored andcommitted
net: usb: lan78xx: Fix memory leak on device unplug by freeing PHY device
Add calls to `phy_device_free` after `fixed_phy_unregister` to fix a memory leak that occurs when the device is unplugged. This ensures proper cleanup of pseudo fixed-link PHYs. Fixes: 89b36fb ("lan78xx: Lan7801 Support for Fixed PHY") Cc: Raghuram Chary J <[email protected]> Signed-off-by: Oleksij Rempel <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 03819ab commit ae7370e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/net/usb/lan78xx.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2380,6 +2380,7 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)
23802380
if (dev->chipid == ID_REV_CHIP_ID_7801_) {
23812381
if (phy_is_pseudo_fixed_link(phydev)) {
23822382
fixed_phy_unregister(phydev);
2383+
phy_device_free(phydev);
23832384
} else {
23842385
phy_unregister_fixup_for_uid(PHY_KSZ9031RNX,
23852386
0xfffffff0);
@@ -4246,8 +4247,10 @@ static void lan78xx_disconnect(struct usb_interface *intf)
42464247

42474248
phy_disconnect(net->phydev);
42484249

4249-
if (phy_is_pseudo_fixed_link(phydev))
4250+
if (phy_is_pseudo_fixed_link(phydev)) {
42504251
fixed_phy_unregister(phydev);
4252+
phy_device_free(phydev);
4253+
}
42514254

42524255
usb_scuttle_anchored_urbs(&dev->deferred);
42534256

0 commit comments

Comments
 (0)