The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 1/2] media: rcar-isp: Fix VSPX reference leaks
@ 2026-08-03  9:05 Linmao Li
  2026-08-03  9:05 ` [PATCH 2/2] media: rcar-isp: Release ISPCORE resources Linmao Li
  2026-08-03 13:43 ` [PATCH 1/2] media: rcar-isp: Fix VSPX reference leaks Jacopo Mondi
  0 siblings, 2 replies; 8+ messages in thread
From: Linmao Li @ 2026-08-03  9:05 UTC (permalink / raw)
  To: Niklas Söderlund, Mauro Carvalho Chehab, Geert Uytterhoeven,
	Magnus Damm
  Cc: Jacopo Mondi, Sakari Ailus, linux-media, linux-renesas-soc,
	linux-kernel, Linmao Li

of_parse_phandle() and of_find_device_by_node() both acquire references,
but the ISPCORE probe never releases them. The device node reference is
leaked immediately, and the VSPX device reference is leaked on probe
failures and on driver removal.

Drop the node reference once the platform device has been looked up and
release the device reference with a devm action.

Fixes: 2151350f60d1 ("media: rcar-isp: Add support for ISPCORE")
Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
---
 drivers/media/platform/renesas/rcar-isp/core.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/media/platform/renesas/rcar-isp/core.c b/drivers/media/platform/renesas/rcar-isp/core.c
index f3dc52c136120..8dafffdd8de68 100644
--- a/drivers/media/platform/renesas/rcar-isp/core.c
+++ b/drivers/media/platform/renesas/rcar-isp/core.c
@@ -781,6 +781,13 @@ int risp_core_registered(struct rcar_isp_core *core, struct v4l2_subdev *sd)
 	return 0;
 }
 
+static void risp_core_put_device(void *data)
+{
+	struct device *dev = data;
+
+	put_device(dev);
+}
+
 static int risp_core_probe_resources(struct rcar_isp_core *core,
 				     struct platform_device *pdev)
 {
@@ -820,9 +827,15 @@ static int risp_core_probe_resources(struct rcar_isp_core *core,
 		return -ENODEV;
 
 	vspx = of_find_device_by_node(of_vspx);
+	of_node_put(of_vspx);
 	if (!vspx)
 		return -ENODEV;
 
+	ret = devm_add_action_or_reset(&pdev->dev, risp_core_put_device,
+				       &vspx->dev);
+	if (ret)
+		return ret;
+
 	/* Attach to VSP-X */
 	core->vspx.dev = &vspx->dev;
 

base-commit: 31152f5b0f8719f92063b8c6196cd5e34106c73d
-- 
2.25.1


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

end of thread, other threads:[~2026-08-04  8:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-03  9:05 [PATCH 1/2] media: rcar-isp: Fix VSPX reference leaks Linmao Li
2026-08-03  9:05 ` [PATCH 2/2] media: rcar-isp: Release ISPCORE resources Linmao Li
2026-08-03 14:17   ` Jacopo Mondi
2026-08-04  2:25     ` Linmao Li
2026-08-04  8:54       ` Niklas Söderlund
2026-08-03 13:43 ` [PATCH 1/2] media: rcar-isp: Fix VSPX reference leaks Jacopo Mondi
2026-08-04  2:05   ` Linmao Li
2026-08-04  8:51     ` Niklas Söderlund

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