Skip to content

Commit 2310c44

Browse files
jwrdegoedesmb49
authored andcommitted
ACPI: scan: Make acpi_bus_get_device() clear return pointer on error
BugLink: https://bugs.launchpad.net/bugs/1915195 commit 78a18fe upstream. Set the acpi_device pointer which acpi_bus_get_device() returns-by- reference to NULL on errors. We've recently had 2 cases where callers of acpi_bus_get_device() did not properly error check the return value, so set the returned- by-reference acpi_device pointer to NULL, because at least some callers of acpi_bus_get_device() expect that to be done on errors. [ rjw: This issue was exposed by commit 71da201 ("ACPI: scan: Defer enumeration of devices with _DEP lists") which caused it to be much more likely to occur on some systems, but the real defect had been introduced by an earlier commit. ] Fixes: 40e7fcb ("ACPI: Add _DEP support to fix battery issue on Asus T100TA") Fixes: bcfcd40 ("usb: split code locating ACPI companion into port and device") Reported-by: Pierre-Louis Bossart <[email protected]> Tested-by: Pierre-Louis Bossart <[email protected]> Diagnosed-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Cc: All applicable <[email protected]> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: William Breathitt Gray <[email protected]>
1 parent 42399ae commit 2310c44

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/acpi/scan.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,8 @@ static int acpi_get_device_data(acpi_handle handle, struct acpi_device **device,
587587
if (!device)
588588
return -EINVAL;
589589

590+
*device = NULL;
591+
590592
status = acpi_get_data_full(handle, acpi_scan_drop_device,
591593
(void **)device, callback);
592594
if (ACPI_FAILURE(status) || !*device) {

0 commit comments

Comments
 (0)