Netdev List
 help / color / mirror / Atom feed
* [PATCH net v3 0/2] net: ethernet: sunplus: spl2sw: fix of_node refcount leaks
@ 2026-06-23  6:41 Shitalkumar Gandhi
  2026-06-23  6:41 ` [PATCH net v3 1/2] net: ethernet: sunplus: spl2sw: fix phy_node refcount leak in remove Shitalkumar Gandhi
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Shitalkumar Gandhi @ 2026-06-23  6:41 UTC (permalink / raw)
  To: Wells Lu
  Cc: Jakub Kicinski, Andrew Lunn, David S. Miller, Eric Dumazet,
	Paolo Abeni, Simon Horman, netdev, linux-kernel,
	Shitalkumar Gandhi

This series fixes of_node refcount leaks in the Sunplus SP7021 ethernet
driver, found by inspection. Compile-tested only; no SP7021 hardware
available here.

Patch 1/2 fixes the phy_node leak in the remove path.
Patch 2/2 fixes multiple leaks in the probe path and depends on the
cleanup contract from patch 1/2.

Changes since v2:
  - Patch 2/2: replaced __free(device_node) scoped cleanup with
    explicit of_node_put() calls on each exit path (Jakub Kicinski).
  - Patch 1/2: no functional change.

Changes since v1:
  - Combined the two related fixes into a single series with cover
    letter, per netdev convention.
  - Added "Compile-tested only" note to both commit messages
    (Andrew Lunn).
  - Dropped Cc: stable@vger.kernel.org -- the leaks only manifest on
    driver unbind/rebind, which is not a path normally exercised on
    this SoC (Andrew Lunn).
  - Fix author email to match Signed-off-by (DCO).

v2: https://lore.kernel.org/netdev/cover.1781552725.git.shitalkumar.gandhi@cambiumnetworks.com/
v1: https://lore.kernel.org/netdev/20260607193029.589736-1-shitalkumar.gandhi@cambiumnetworks.com/
    https://lore.kernel.org/netdev/20260607193711.601544-1-shitalkumar.gandhi@cambiumnetworks.com/

Shitalkumar Gandhi (2):
  net: ethernet: sunplus: spl2sw: fix phy_node refcount leak in remove
  net: ethernet: sunplus: spl2sw: fix multiple of_node refcount leaks in
    probe

 drivers/net/ethernet/sunplus/spl2sw_driver.c | 23 +++++++++++++++++---
 drivers/net/ethernet/sunplus/spl2sw_phy.c    |  6 +++--
 2 files changed, 24 insertions(+), 5 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net v3 1/2] net: ethernet: sunplus: spl2sw: fix phy_node refcount leak in remove
  2026-06-23  6:41 [PATCH net v3 0/2] net: ethernet: sunplus: spl2sw: fix of_node refcount leaks Shitalkumar Gandhi
@ 2026-06-23  6:41 ` Shitalkumar Gandhi
  2026-06-23 11:24   ` Andrew Lunn
  2026-06-25  2:35 ` [PATCH net v3 0/2] net: ethernet: sunplus: spl2sw: fix of_node refcount leaks Jakub Kicinski
  2026-06-25  2:40 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Shitalkumar Gandhi @ 2026-06-23  6:41 UTC (permalink / raw)
  To: Wells Lu
  Cc: Jakub Kicinski, Andrew Lunn, David S. Miller, Eric Dumazet,
	Paolo Abeni, Simon Horman, netdev, linux-kernel,
	Shitalkumar Gandhi

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: fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021")
Signed-off-by: Shitalkumar Gandhi <shitalkumar.gandhi@cambiumnetworks.com>
---
 drivers/net/ethernet/sunplus/spl2sw_phy.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/sunplus/spl2sw_phy.c b/drivers/net/ethernet/sunplus/spl2sw_phy.c
index 6f899e48f51d..a4889c52e00e 100644
--- a/drivers/net/ethernet/sunplus/spl2sw_phy.c
+++ b/drivers/net/ethernet/sunplus/spl2sw_phy.c
@@ -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);
 		}
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net v3 1/2] net: ethernet: sunplus: spl2sw: fix phy_node refcount leak in remove
  2026-06-23  6:41 ` [PATCH net v3 1/2] net: ethernet: sunplus: spl2sw: fix phy_node refcount leak in remove Shitalkumar Gandhi
@ 2026-06-23 11:24   ` Andrew Lunn
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2026-06-23 11:24 UTC (permalink / raw)
  To: Shitalkumar Gandhi
  Cc: Wells Lu, Jakub Kicinski, David S. Miller, Eric Dumazet,
	Paolo Abeni, Simon Horman, netdev, linux-kernel,
	Shitalkumar Gandhi

On Tue, Jun 23, 2026 at 12:11:42PM +0530, Shitalkumar Gandhi wrote:
> 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: fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021")
> Signed-off-by: Shitalkumar Gandhi <shitalkumar.gandhi@cambiumnetworks.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net v3 0/2] net: ethernet: sunplus: spl2sw: fix of_node refcount leaks
  2026-06-23  6:41 [PATCH net v3 0/2] net: ethernet: sunplus: spl2sw: fix of_node refcount leaks Shitalkumar Gandhi
  2026-06-23  6:41 ` [PATCH net v3 1/2] net: ethernet: sunplus: spl2sw: fix phy_node refcount leak in remove Shitalkumar Gandhi
@ 2026-06-25  2:35 ` Jakub Kicinski
  2026-06-25  2:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2026-06-25  2:35 UTC (permalink / raw)
  To: Shitalkumar Gandhi
  Cc: Wells Lu, Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
	Simon Horman, netdev, linux-kernel, Shitalkumar Gandhi

On Tue, 23 Jun 2026 12:11:41 +0530 Shitalkumar Gandhi wrote:
> Shitalkumar Gandhi (2):
>   net: ethernet: sunplus: spl2sw: fix phy_node refcount leak in remove
>   net: ethernet: sunplus: spl2sw: fix multiple of_node refcount leaks in
>     probe

Only the first patch reached the list

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net v3 0/2] net: ethernet: sunplus: spl2sw: fix of_node refcount leaks
  2026-06-23  6:41 [PATCH net v3 0/2] net: ethernet: sunplus: spl2sw: fix of_node refcount leaks Shitalkumar Gandhi
  2026-06-23  6:41 ` [PATCH net v3 1/2] net: ethernet: sunplus: spl2sw: fix phy_node refcount leak in remove Shitalkumar Gandhi
  2026-06-25  2:35 ` [PATCH net v3 0/2] net: ethernet: sunplus: spl2sw: fix of_node refcount leaks Jakub Kicinski
@ 2026-06-25  2:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-06-25  2:40 UTC (permalink / raw)
  To: Shitalkumar Gandhi
  Cc: wellslutw, kuba, andrew, davem, edumazet, pabeni, horms, netdev,
	linux-kernel, shitalkumar.gandhi

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 23 Jun 2026 12:11:41 +0530 you wrote:
> This series fixes of_node refcount leaks in the Sunplus SP7021 ethernet
> driver, found by inspection. Compile-tested only; no SP7021 hardware
> available here.
> 
> Patch 1/2 fixes the phy_node leak in the remove path.
> Patch 2/2 fixes multiple leaks in the probe path and depends on the
> cleanup contract from patch 1/2.
> 
> [...]

Here is the summary with links:
  - [net,v3,1/2] net: ethernet: sunplus: spl2sw: fix phy_node refcount leak in remove
    https://git.kernel.org/netdev/net/c/a9e29dcd8a84

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-06-25  2:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23  6:41 [PATCH net v3 0/2] net: ethernet: sunplus: spl2sw: fix of_node refcount leaks Shitalkumar Gandhi
2026-06-23  6:41 ` [PATCH net v3 1/2] net: ethernet: sunplus: spl2sw: fix phy_node refcount leak in remove Shitalkumar Gandhi
2026-06-23 11:24   ` Andrew Lunn
2026-06-25  2:35 ` [PATCH net v3 0/2] net: ethernet: sunplus: spl2sw: fix of_node refcount leaks Jakub Kicinski
2026-06-25  2:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox