mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 03:27:30 -04:00
net: ethernet: sunplus: spl2sw: fix phy_node refcount leak in remove
mac->phy_node is acquired via of_parse_phandle() in spl2sw_probe() and
stored in the mac private data, transferring ownership of the
device_node reference to mac. On driver removal, spl2sw_phy_remove()
disconnects the PHY but never drops that reference, so each
probe-then-remove cycle leaks one of_node refcount per port permanently.
Drop the reference after phy_disconnect(). While at it, remove the
redundant inner "if (ndev)" check; comm->ndev[i] was just verified
non-NULL on the line above.
Compile-tested only; no SP7021 hardware available.
Fixes: fd3040b939 ("net: ethernet: Add driver for Sunplus SP7021")
Signed-off-by: Shitalkumar Gandhi <shitalkumar.gandhi@cambiumnetworks.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/f3bdd4c91f3e2269b4e256075f9dc70808b1b8e9.1782195965.git.shitalkumar.gandhi@cambiumnetworks.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
636838ebb7
commit
a9e29dcd8a
@@ -79,12 +79,14 @@ int spl2sw_phy_connect(struct spl2sw_common *comm)
|
||||
void spl2sw_phy_remove(struct spl2sw_common *comm)
|
||||
{
|
||||
struct net_device *ndev;
|
||||
struct spl2sw_mac *mac;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_NETDEV_NUM; i++)
|
||||
if (comm->ndev[i]) {
|
||||
ndev = comm->ndev[i];
|
||||
if (ndev)
|
||||
phy_disconnect(ndev->phydev);
|
||||
mac = netdev_priv(ndev);
|
||||
phy_disconnect(ndev->phydev);
|
||||
of_node_put(mac->phy_node);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user