]> git.baikalelectronics.ru Git - kernel.git/commit
ACPI: fix NULL pointer dereference
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 24 Jul 2021 22:25:54 +0000 (15:25 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 24 Jul 2021 22:25:54 +0000 (15:25 -0700)
commit2174f188ea3e7567f203c9618ac69aabbd790e1e
tree2ff10e7274b864582aeba2a4cf084285a493dac4
parented70c94010f11a3ae9ef0329b52ada5b35acd7a8
ACPI: fix NULL pointer dereference

Commit ba40affef143 ("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>
include/acpi/acpi_bus.h