[PATCH] net: dpaa: Fix tbidev reference leak in dtsec_initialization()
From: Wentao Liang
Date: Thu Sep 17 2026 - 07:08:09 EST
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@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
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