Skip to contentSkip to conversation

net: dpaa2: ptp: fix device node reference leak on remove

PATCH Applied Guangshuo Li 2 participants 2 messages Sep 16 – Sep 19

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

PATCH 1/1 net: dpaa2: ptp: fix device node reference leak on remove

dpaa2_ptp_probe() gets a referenced device node with of_find_compatible_node() and stores it in dev->of_node.

The probe failure paths release this reference with of_node_put(). However, after a successful probe, dpaa2_ptp_remove() tears down the PTP and MC resources without dropping the device node reference.

Release dev->of_node during driver removal and clear the pointer after dropping the reference.

This issue was found by manual code inspection.

Fixes d346c9e86d86 ("dpaa2-ptp: reuse ptp_qoriq driver")
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c +2 -0
index 4497e3c0456d..440319a1e775 100644
@@ -232,6 +232,8 @@ static void dpaa2_ptp_remove(struct fsl_mc_device *mc_dev)
 	fsl_mc_free_irqs(mc_dev);
 	dprtc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
 	fsl_mc_portal_free(mc_dev->mc_io);
+	of_node_put(dev->of_node);
+	dev->of_node = NULL;
 }
 
 static const struct fsl_mc_device_id dpaa2_ptp_match_id_table[] = {
Signature · 1 line
2.43.0
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Wed, 16 Sep 2026 11:00:15 +0800 you wrote:

dpaa2_ptp_probe() gets a referenced device node with of_find_compatible_node() and stores it in dev->of_node.

The probe failure paths release this reference with of_node_put(). However, after a successful probe, dpaa2_ptp_remove() tears down the PTP and MC resources without dropping the device node reference.

[...]

Here is the summary with links:
- net: dpaa2: ptp: fix device node reference leak on remove

    https://git.kernel.org/netdev/net-next/c/9211c455dee8

You are awesome, thank you!

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