Skip to content

Commit fc68f42

Browse files
committed
ACPI: fix NULL pointer dereference
Commit 71f6428 ("ACPI: utils: Fix reference counting in for_each_acpi_dev_match()") started doing "acpi_dev_put()" on a pointer that was possibly NULL. That fails miserably, because that helper inline function is not set up to handle that case. Just make acpi_dev_put() silently accept a NULL pointer, rather than calling down to put_device() with an invalid offset off that NULL pointer. Link: https://lore.kernel.org/lkml/[email protected]/ Reported-and-tested-by: Jens Axboe <[email protected]> Tested-by: Daniel Scally <[email protected]> Cc: Andy Shevchenko <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 7ffca2b commit fc68f42

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

include/acpi/acpi_bus.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,8 @@ static inline struct acpi_device *acpi_dev_get(struct acpi_device *adev)
720720

721721
static inline void acpi_dev_put(struct acpi_device *adev)
722722
{
723-
put_device(&adev->dev);
723+
if (adev)
724+
put_device(&adev->dev);
724725
}
725726

726727
struct acpi_device *acpi_bus_get_acpi_device(acpi_handle handle);

0 commit comments

Comments
 (0)