]> Git Repo - linux.git/commitdiff
ACPI: fix NULL pointer dereference
authorLinus Torvalds <[email protected]>
Sat, 24 Jul 2021 22:25:54 +0000 (15:25 -0700)
committerLinus Torvalds <[email protected]>
Sat, 24 Jul 2021 22:25:54 +0000 (15:25 -0700)
Commit 71f642833284 ("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]>
include/acpi/acpi_bus.h

index b9d434a936320bdbfaadd4d6a2ee14e45d383811..13d93371790ec94074c7ab8f0d169a68570a4624 100644 (file)
@@ -720,7 +720,8 @@ static inline struct acpi_device *acpi_dev_get(struct acpi_device *adev)
 
 static inline void acpi_dev_put(struct acpi_device *adev)
 {
-       put_device(&adev->dev);
+       if (adev)
+               put_device(&adev->dev);
 }
 
 struct acpi_device *acpi_bus_get_acpi_device(acpi_handle handle);
This page took 0.059174 seconds and 4 git commands to generate.