Skip to content

Commit 3642d0a

Browse files
lgs2513gregkh
authored andcommitted
gpu: host1x: Fix device reference leak in host1x_device_parse_dt() error path
commit e75717f upstream. 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. The issue was identified by a static analysis tool I developed and confirmed by manual review. Fix this by using put_device() in the host1x_device_parse_dt() failure path. Fixes: f4c5cf8 ("gpu: host1x: Provide a proper struct bus_type") Cc: stable@vger.kernel.org Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com> Acked-by: Mikko Perttunen <mperttunen@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com> Link: https://patch.msgid.link/20260413141526.2961841-1-lgs201920130244@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 00c06ef commit 3642d0a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/gpu/host1x/bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ static int host1x_device_add(struct host1x *host1x,
474474

475475
err = host1x_device_parse_dt(device, driver);
476476
if (err < 0) {
477-
kfree(device);
477+
put_device(&device->dev);
478478
return err;
479479
}
480480

0 commit comments

Comments
 (0)