From: Yige Jiang <yigejiang86@gmail.com>
To: Madalin Bucur <madalin.bucur@nxp.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Yige Jiang <yigejiang86@gmail.com>,
Sean Anderson <sean.anderson@linux.dev>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net] fsl/fman: Drop device references when dpaa_eth_add_device() fails
Date: Thu, 26 Nov 2026 17:37:56 +0800 [thread overview]
Message-ID: <rc-b1-20261110-vc-177-85d2478ac4b9@gmail.com> (raw)
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)
next reply other threads:[~2026-11-26 9:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 9:37 Yige Jiang [this message]
2026-11-26 9:42 ` netdev-bot+sinfo
2026-11-26 11:53 ` Yige Jiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=rc-b1-20261110-vc-177-85d2478ac4b9@gmail.com \
--to=yigejiang86@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=madalin.bucur@nxp.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sean.anderson@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®