From: Wentao Liang <vulab@iscas.ac.cn>
To: Madalin Bucur <madalin.bucur@nxp.com>,
Sean Anderson <sean.anderson@linux.dev>,
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: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] net: fman: drop the FMan device reference after port probe
Date: Tue, 3 Nov 2026 10:05:32 +0000 [thread overview]
Message-ID: <20261103100532.1309969-1-vulab@iscas.ac.cn> (raw)
fman_port_probe() looks up the parent FMan platform device with
of_find_device_by_node(), which takes a reference on the embedded
struct device. The reference is released on the error paths, but not
after a successful probe, and the __devm_request_region() failure path
jumps directly to freeing the port.
As a result the reference is never dropped. Put the FMan device and
the port node before returning success, and route the failed region
request through the existing cleanup labels as well.
Fixes: 18a6c85fcc78 ("fsl/fman: Add FMan Port Support")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/net/ethernet/freescale/fman/fman_port.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c b/drivers/net/ethernet/freescale/fman/fman_port.c
index 1b8fef69114e..faf1e35399cd 100644
--- a/drivers/net/ethernet/freescale/fman/fman_port.c
+++ b/drivers/net/ethernet/freescale/fman/fman_port.c
@@ -1850,15 +1850,13 @@ static int fman_port_probe(struct platform_device *of_dev)
port->dts_params.fman = fman;
- of_node_put(port_node);
-
dev_res = __devm_request_region(port->dev, &res, res.start,
resource_size(&res), "fman-port");
if (!dev_res) {
dev_err(port->dev, "%s: __devm_request_region() failed\n",
__func__);
err = -EINVAL;
- goto free_port;
+ goto put_device;
}
port->dts_params.base_addr = devm_ioremap(port->dev, res.start,
@@ -1868,13 +1866,14 @@ static int fman_port_probe(struct platform_device *of_dev)
dev_set_drvdata(&of_dev->dev, port);
+ of_node_put(port_node);
+ put_device(&fm_pdev->dev);
return 0;
put_device:
put_device(&fm_pdev->dev);
return_err:
of_node_put(port_node);
-free_port:
kfree(port);
return err;
}
--
2.34.1
next reply other threads:[~2026-11-03 10:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 10:05 Wentao Liang [this message]
2026-11-03 10:09 ` netdev-bot+sinfo
2026-11-03 10:25 ` Krzysztof Kozlowski
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=20261103100532.1309969-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--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 \
--cc=stable@vger.kernel.org \
/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®