mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] net: fman: drop the FMan device reference after port probe
@ 2026-11-03 10:05 Wentao Liang
  2026-11-03 10:09 ` netdev-bot+sinfo
  2026-11-03 10:25 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-03 10:05 UTC (permalink / raw)
  To: Madalin Bucur, Sean Anderson, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel, Wentao Liang, stable

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


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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 10:05 [PATCH] net: fman: drop the FMan device reference after port probe Wentao Liang
2026-11-03 10:09 ` netdev-bot+sinfo
2026-11-03 10:25 ` Krzysztof Kozlowski

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®