Skip to contentSkip to conversation

dpaa2-eth: put MAC endpoint device on disconnect

PATCH Applied Guangshuo Li 3 participants 4 messages Jul 8 – Jul 21

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dpaa2-eth: put MAC endpoint device on disconnect

fsl_mc_get_endpoint() returns the MAC endpoint device with a reference taken through device_find_child(). The Ethernet connect path stores that device in mac->mc_dev and keeps it for the lifetime of the connected MAC object.

However, the disconnect path only disconnects and closes the MAC before freeing the dpaa2_mac object. It does not drop the endpoint device reference stored in mac->mc_dev, so every successful connect leaks that device reference when the MAC is later disconnected.

Drop the endpoint device reference after closing the MAC and before freeing the dpaa2_mac object.

Fixes 719479230893 ("dpaa2-eth: add MAC/PHY support through phylink")
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +1 -0
index 9335703768a9..764d2a09668f 100644
@@ -4732,6 +4732,7 @@ static void dpaa2_eth_disconnect_mac(struct dpaa2_eth_priv *priv)
 		dpaa2_mac_disconnect(mac);
 
 	dpaa2_mac_close(mac);
+	put_device(&mac->mc_dev->dev);
 	kfree(mac);
 }
 
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Guangshuo Li

fsl_mc_get_endpoint() returns the MAC endpoint device with a reference taken through device_find_child(). The Ethernet connect path stores that device in mac->mc_dev and keeps it for the lifetime of the connected MAC object.

However, the disconnect path only disconnects and closes the MAC before freeing the dpaa2_mac object. It does not drop the endpoint device reference stored in mac->mc_dev, so every successful connect leaks that device reference when the MAC is later disconnected.

Quoted 5 lines

Drop the endpoint device reference after closing the MAC and before freeing the dpaa2_mac object.

Fixes 719479230893 ("dpaa2-eth: add MAC/PHY support through phylink")

Next time, please mention the targeted tree (net-next vs net).

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Guangshuo Li
Quoted 10 lines · Guangshuo Li

fsl_mc_get_endpoint() returns the MAC endpoint device with a reference taken through device_find_child(). The Ethernet connect path stores that device in mac->mc_dev and keeps it for the lifetime of the connected MAC object.

However, the disconnect path only disconnects and closes the MAC before freeing the dpaa2_mac object. It does not drop the endpoint device reference stored in mac->mc_dev, so every successful connect leaks that device reference when the MAC is later disconnected.

Quoted 5 lines

Drop the endpoint device reference after closing the MAC and before freeing the dpaa2_mac object.

Fixes 719479230893 ("dpaa2-eth: add MAC/PHY support through phylink")
#3 lore raw
In reply to Guangshuo Li
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 11 lines · On Wed, 8 Jul 2026 19:17:37 +0800 you wrote:

fsl_mc_get_endpoint() returns the MAC endpoint device with a reference taken through device_find_child(). The Ethernet connect path stores that device in mac->mc_dev and keeps it for the lifetime of the connected MAC object.

However, the disconnect path only disconnects and closes the MAC before freeing the dpaa2_mac object. It does not drop the endpoint device reference stored in mac->mc_dev, so every successful connect leaks that device reference when the MAC is later disconnected.

[...]

Here is the summary with links:
- dpaa2-eth: put MAC endpoint device on disconnect

    https://git.kernel.org/netdev/net/c/b4b201cc93ff

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html