summaryrefslogtreecommitdiffstats
path: root/include/acpi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2021-07-24 15:25:54 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-08-08 09:05:23 +0200
commitcae3fa3d8165761f3000f523b11cfa1cd35206bc (patch)
tree2d8e633669a0935371724dd5e72cef045ab48bdc /include/acpi
parent98b070694f4570908a0e8ea5afb68d81b0aa2051 (diff)
downloadlinux-stable-cae3fa3d8165761f3000f523b11cfa1cd35206bc.tar.gz
linux-stable-cae3fa3d8165761f3000f523b11cfa1cd35206bc.tar.bz2
linux-stable-cae3fa3d8165761f3000f523b11cfa1cd35206bc.zip
ACPI: fix NULL pointer dereference
[ Upstream commit fc68f42aa737dc15e7665a4101d4168aadb8e4c4 ] 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/a607c149-6bf6-0fd0-0e31-100378504da2@kernel.dk/ Reported-and-tested-by: Jens Axboe <axboe@kernel.dk> Tested-by: Daniel Scally <djrscally@gmail.com> Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/acpi')
-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 37dac195adbb..6ad3b89a8a2e 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -689,7 +689,8 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv);
static inline void acpi_dev_put(struct acpi_device *adev)
{
- put_device(&adev->dev);
+ if (adev)
+ put_device(&adev->dev);
}
#else /* CONFIG_ACPI */