The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] remoteproc: scp: fix device reference leak on failed lookup
@ 2026-07-06  6:56 Johan Hovold
  0 siblings, 0 replies; only message in thread
From: Johan Hovold @ 2026-07-06  6:56 UTC (permalink / raw)
  To: Bjorn Andersson, Mathieu Poirier
  Cc: Matthias Brugger, AngeloGioacchino Del Regno, Guangshuo Li,
	linux-remoteproc, linux-mediatek, linux-kernel, Johan Hovold,
	stable, Erin Lo

Make sure to drop the reference taken to the SCP device when attempting
to look up its driver data before the driver has been bound.

Note that holding a reference to a device does not prevent its driver
data from going away.

Fixes: 63c13d61eafe ("remoteproc/mediatek: add SCP support for mt8183")
Cc: stable@vger.kernel.org	# 5.6
Cc: Erin Lo <erin.lo@mediatek.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/remoteproc/mtk_scp.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
index 85a74c9ec521..436656bdfa8b 100644
--- a/drivers/remoteproc/mtk_scp.c
+++ b/drivers/remoteproc/mtk_scp.c
@@ -36,6 +36,7 @@ struct mtk_scp *scp_get(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct device_node *scp_node;
 	struct platform_device *scp_pdev;
+	struct mtk_scp *scp;
 
 	scp_node = of_parse_phandle(dev->of_node, "mediatek,scp", 0);
 	if (!scp_node) {
@@ -51,7 +52,13 @@ struct mtk_scp *scp_get(struct platform_device *pdev)
 		return NULL;
 	}
 
-	return platform_get_drvdata(scp_pdev);
+	scp = platform_get_drvdata(scp_pdev);
+	if (!scp) {
+		put_device(&scp_pdev->dev);
+		return NULL;
+	}
+
+	return scp;
 }
 EXPORT_SYMBOL_GPL(scp_get);
 
-- 
2.54.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-06  6:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06  6:56 [PATCH] remoteproc: scp: fix device reference leak on failed lookup Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox