aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <[email protected]>2021-07-24 15:25:54 -0700
committerLinus Torvalds <[email protected]>2021-07-24 15:25:54 -0700
commitfc68f42aa737dc15e7665a4101d4168aadb8e4c4 (patch)
tree2ff10e7274b864582aeba2a4cf084285a493dac4
parent7ffca2bb9d8bf6813db50364b1dd2c02f58fb65e (diff)
ACPI: fix NULL pointer dereference
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]>
-rw-r--r--include/acpi/acpi_bus.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index b9d434a93632..13d93371790e 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -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);