net: usb: lan78xx: Fix memory leak on device unplug by freeing PHY device
[ Upstream commit ae7370e61c5d8f5bcefc2d4fca724bd4e9bbf789 ] 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: 89b36fb5e532 ("lan78xx: Lan7801 Support for Fixed PHY") Cc: Raghuram Chary J <raghuramchary.jallipalli@microchip.com> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://patch.msgid.link/20241116130558.1352230-2-o.rempel@pengutronix.de Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
9400c8e684
commit
7b5b521e02
1 changed files with 4 additions and 1 deletions
|
@ -2157,6 +2157,7 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)
|
|||
if (dev->chipid == ID_REV_CHIP_ID_7801_) {
|
||||
if (phy_is_pseudo_fixed_link(phydev)) {
|
||||
fixed_phy_unregister(phydev);
|
||||
phy_device_free(phydev);
|
||||
} else {
|
||||
phy_unregister_fixup_for_uid(PHY_KSZ9031RNX,
|
||||
0xfffffff0);
|
||||
|
@ -3835,8 +3836,10 @@ static void lan78xx_disconnect(struct usb_interface *intf)
|
|||
|
||||
phy_disconnect(net->phydev);
|
||||
|
||||
if (phy_is_pseudo_fixed_link(phydev))
|
||||
if (phy_is_pseudo_fixed_link(phydev)) {
|
||||
fixed_phy_unregister(phydev);
|
||||
phy_device_free(phydev);
|
||||
}
|
||||
|
||||
unregister_netdev(net);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue