mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] fsl/fman: Drop device references when dpaa_eth_add_device() fails
@ 2026-11-26  9:37 Yige Jiang
  2026-11-26  9:42 ` netdev-bot+sinfo
  0 siblings, 1 reply; 3+ messages in thread
From: Yige Jiang @ 2026-11-26  9:37 UTC (permalink / raw)
  To: Madalin Bucur, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Yige Jiang, Sean Anderson, netdev, linux-kernel

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@gmail.com>
---
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)


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

end of thread, other threads:[~2026-11-26 11:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26  9:37 [PATCH net] fsl/fman: Drop device references when dpaa_eth_add_device() fails Yige Jiang
2026-11-26  9:42 ` netdev-bot+sinfo
2026-11-26 11:53   ` Yige Jiang

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®