Skip to content

Commit 9c0acc1

Browse files
lgs2513rafaeljw
authored andcommitted
ACPI: scan: Use acpi_dev_put() in object add error paths
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>
1 parent 2e31b16 commit 9c0acc1

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
@@ -987,7 +987,7 @@ struct acpi_device *acpi_add_power_resource(acpi_handle handle)
987987
return device;
988988

989989
err:
990-
acpi_release_power_resource(&device->dev);
990+
acpi_dev_put(device);
991991
return NULL;
992992
}
993993

drivers/acpi/scan.c

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

19021902
if (result) {
1903-
acpi_device_release(&device->dev);
1903+
acpi_dev_put(device);
19041904
return result;
19051905
}
19061906

0 commit comments

Comments
 (0)