mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] net: dpaa: Fix tbidev reference leak in dtsec_initialization()
@ 2026-09-17 11:05 Wentao Liang
  2026-09-21 12:04 ` netdev-bot+sashiko
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-17 11:05 UTC (permalink / raw)
  To: andrew+netdev
  Cc: davem, edumazet, kuba, linux-kernel, madalin.bucur, netdev,
	pabeni, sean.anderson, Wentao Liang, stable

dtsec_initialization() takes a reference on the PCS mdio device with
of_mdio_find_device(), but only releases it in dtsec_free(), which is
called from the error paths. The successful path returns without
dropping it, leaking the reference.

Release the reference once the PCS has been set up. The device stays
registered for as long as the FMan device, which mac_dev holds a
reference to.

Fixes: 5d93cfcf7360 ("net: dpaa: Convert to phylink")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/net/ethernet/freescale/fman/fman_dtsec.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
index fe35703c509e..2a503bc5bc28 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -1492,6 +1492,12 @@ int dtsec_initialization(struct mac_device *mac_dev,
 	dev_info(mac_dev->dev, "FMan dTSEC version: 0x%08x\n",
 		 ioread32be(&dtsec->regs->tsec_id));
 
+	/* The PCS device is registered as long as the FMan device, of which
+	 * mac_dev holds a reference, so the reference taken above is not
+	 * needed anymore.
+	 */
+	put_device(&dtsec->tbidev->dev);
+
 	goto _return;
 
 _return_fm_mac_free:
-- 
2.34.1


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

end of thread, other threads:[~2026-09-21 12:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 11:05 [PATCH] net: dpaa: Fix tbidev reference leak in dtsec_initialization() Wentao Liang
2026-09-21 12:04 ` netdev-bot+sashiko

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

all inboxes | Powered by JetHome®