[PATCH net] net: phy: add a note about refcounting

Subsystems: ethernet phy library, networking drivers, the rest

STALE1765d

2 messages, 2 authors, 2021-12-13 · open the first message on its own page

[PATCH net] net: phy: add a note about refcounting

From: Russell King (Oracle) <hidden>
Date: 2021-12-13 11:05:17

Recently, a patch has been submitted to "fix" the refcounting for a DT
node in of_mdiobus_link_mdiodev(). This is not a leaked refcount. The
refcount is passed to the new device.

Sadly, coccicheck identifies this location as a leaked refcount, which
means we're likely to keep getting patches to "fix" this. However,
fixing this will cause breakage. Add a comment to state that the lack
of of_node_put() here is intentional.

Signed-off-by: Russell King (Oracle) <redacted>
---
 drivers/net/phy/mdio_bus.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index c204067f1890..c198722e4871 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -460,6 +460,9 @@ static void of_mdiobus_link_mdiodev(struct mii_bus *bus,
 
 		if (addr == mdiodev->addr) {
 			device_set_node(dev, of_fwnode_handle(child));
+			/* The refcount on "child" is passed to the mdio
+			 * device. Do _not_ use of_node_put(child) here.
+			 */
 			return;
 		}
 	}
-- 
2.30.2

Re: [PATCH net] net: phy: add a note about refcounting

From: patchwork-bot+netdevbpf@kernel.org
Date: 2021-12-13 15:00:12

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller [off-list ref]:

On Mon, 13 Dec 2021 11:05:13 +0000 you wrote:
Recently, a patch has been submitted to "fix" the refcounting for a DT
node in of_mdiobus_link_mdiodev(). This is not a leaked refcount. The
refcount is passed to the new device.

Sadly, coccicheck identifies this location as a leaked refcount, which
means we're likely to keep getting patches to "fix" this. However,
fixing this will cause breakage. Add a comment to state that the lack
of of_node_put() here is intentional.

[...]
Here is the summary with links:
  - [net] net: phy: add a note about refcounting
    https://git.kernel.org/netdev/net/c/d33dae51645c

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

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help