[PATCH net] fsl/fman: Drop device references when dpaa_eth_add_device() fails

From: Yige Jiang

Date: Thu Nov 26 2026 - 04:38:26 EST


When dpaa_eth_add_device() fails at the end of mac_probe(), the error
is returned directly. This skips the _return_dev_arr_put and
_return_dev_put labels, so the references held on the FMan device and
on both FMan port devices are never dropped. mac_remove() would drop
them, but it does not run after a failed probe.

Jump to _return_dev_arr_put instead, as the init() failure above does.
The devices are created from the device tree and are not normally
removed, so the leaked references have no visible effect in practice.
The MAC state allocated by init() is still not freed on this path, as
in mac_remove(); that needs a separate change.

Fixes: 1dec67e0d9fb ("fsl/fman: Fix refcount handling of fman-related devices")
Signed-off-by: Yige Jiang <yigejiang86@xxxxxxxxx>
---
Based on linux-next next-20261109 (630059a5a632).
Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_FSL_FMAN=y, CONFIG_FSL_DPAA=y, CONFIG_COMPILE_TEST=y; baseline and patched mac.o, no new warnings.
No hardware or runtime test was performed.

The path needs dpaa_eth_add_device() to fail (allocation failure or a
platform_device_add() error) after the MAC was initialized.

drivers/net/ethernet/freescale/fman/mac.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
index 29c2fa2be837..4180cec15c0f 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -307,6 +307,7 @@ static int mac_probe(struct platform_device *_of_dev)
dev_err(dev, "failed to add Ethernet platform device for MAC %d\n",
priv->cell_index);
priv->eth_dev = NULL;
+ goto _return_dev_arr_put;
}

return err;

base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47
--
2.50.1 (Apple Git-155)