public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] gpu: host1x: Fix device reference leak in host1x_device_parse_dt() error path
@ 2026-04-12 12:06 Guangshuo Li
  2026-04-13  9:12 ` Claude review: " Claude Code Review Bot
  2026-04-13  9:12 ` Claude Code Review Bot
  0 siblings, 2 replies; 5+ messages in thread
From: Guangshuo Li @ 2026-04-12 12:06 UTC (permalink / raw)
  To: Thierry Reding, Mikko Perttunen, David Airlie, Simona Vetter,
	Mark Zhang, Sean Paul, dri-devel, linux-tegra, linux-kernel
  Cc: Guangshuo Li

After device_initialize(), the embedded struct device in struct
host1x_device should be released through the device core with
put_device().

In host1x_device_add(), if host1x_device_parse_dt() fails, the current
error path frees the object directly with kfree(device). That bypasses
the normal device lifetime handling and leaks the reference held on the
embedded struct device.

Fix this by using put_device() in the host1x_device_parse_dt() failure
path.

Fixes: f4c5cf88fbd50 ("gpu: host1x: Provide a proper struct bus_type")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/gpu/host1x/bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index 723a80895cd4..f97567e6ae87 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -452,7 +452,7 @@ static int host1x_device_add(struct host1x *host1x,
 
 	err = host1x_device_parse_dt(device, driver);
 	if (err < 0) {
-		kfree(device);
+		put_device(&device->dev);
 		return err;
 	}
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH v2] gpu: host1x: Fix device reference leak in host1x_device_parse_dt() error path
@ 2026-04-12 12:26 Guangshuo Li
  2026-04-13  9:07 ` Claude review: " Claude Code Review Bot
  2026-04-13  9:07 ` Claude Code Review Bot
  0 siblings, 2 replies; 5+ messages in thread
From: Guangshuo Li @ 2026-04-12 12:26 UTC (permalink / raw)
  To: Thierry Reding, Mikko Perttunen, David Airlie, Simona Vetter,
	Sean Paul, Mark Zhang, dri-devel, linux-tegra, linux-kernel
  Cc: Guangshuo Li, stable

After device_initialize(), the embedded struct device in struct
host1x_device should be released through the device core with
put_device().

In host1x_device_add(), if host1x_device_parse_dt() fails, the current
error path frees the object directly with kfree(device). That bypasses
the normal device lifetime handling and leaks the reference held on the
embedded struct device.

Fix this by using put_device() in the host1x_device_parse_dt() failure
path.

Fixes: f4c5cf88fbd50 ("gpu: host1x: Provide a proper struct bus_type")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
v2:
  - add Cc: stable@vger.kernel.org

 drivers/gpu/host1x/bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index 723a80895cd4..f97567e6ae87 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -452,7 +452,7 @@ static int host1x_device_add(struct host1x *host1x,
 
 	err = host1x_device_parse_dt(device, driver);
 	if (err < 0) {
-		kfree(device);
+		put_device(&device->dev);
 		return err;
 	}
 
-- 
2.43.0


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

end of thread, other threads:[~2026-04-13  9:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-12 12:06 [PATCH] gpu: host1x: Fix device reference leak in host1x_device_parse_dt() error path Guangshuo Li
2026-04-13  9:12 ` Claude review: " Claude Code Review Bot
2026-04-13  9:12 ` Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-04-12 12:26 [PATCH v2] " Guangshuo Li
2026-04-13  9:07 ` Claude review: " Claude Code Review Bot
2026-04-13  9:07 ` Claude Code Review Bot

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