Skip to content

Commit 7ef8e29

Browse files
lgs2513gregkh
authored andcommitted
ACPI: scan: Use acpi_dev_put() in object add error paths
commit 9c0acc1 upstream. After acpi_init_device_object(), the lifetime of struct acpi_device is managed by the driver core through reference counting. Both acpi_add_power_resource() and acpi_add_single_object() call acpi_init_device_object() and then invoke acpi_device_add(). If that fails, their error paths call the release callback directly instead of dropping the device reference through acpi_dev_put(). This bypasses the normal device lifetime rules and frees the object without releasing the reference acquired by device_initialize(), which may lead to a refcount leak. The issue was identified by a static analysis tool I developed and confirmed by manual review. Fix both error paths by using acpi_dev_put() and let the release callback handle the final cleanup. Fixes: 781d737 ("ACPI: Drop power resources driver") Fixes: 718fb0d ("ACPI: fix NULL bug for HID/UID string") Cc: All applicable <stable@vger.kernel.org> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com> Link: https://patch.msgid.link/20260413135343.2884481-1-lgs201920130244@gmail.com Signed-off-by: Rafael J. Wysocki <rjw@rjwysocki.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 18dd358 commit 7ef8e29

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/acpi/power.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ struct acpi_device *acpi_add_power_resource(acpi_handle handle)
986986
return device;
987987

988988
err:
989-
acpi_release_power_resource(&device->dev);
989+
acpi_dev_put(device);
990990
return NULL;
991991
}
992992

drivers/acpi/scan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,7 @@ static int acpi_add_single_object(struct acpi_device **child,
19141914
result = acpi_device_add(device);
19151915

19161916
if (result) {
1917-
acpi_device_release(&device->dev);
1917+
acpi_dev_put(device);
19181918
return result;
19191919
}
19201920

0 commit comments

Comments
 (0)