diff options
author | Nikita Kiryushin <kiryushin@ancud.ru> | 2023-11-09 16:49:25 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-01-25 14:33:31 -0800 |
commit | 556f02699d33c1f40b1b31bd25828ce08fa165d8 (patch) | |
tree | 12edde41420a8a04c866757deacc225beaede4fc | |
parent | 238f46e6bbe689fb70d3933ffc2b9b7b0caf38b9 (diff) | |
download | linux-stable-556f02699d33c1f40b1b31bd25828ce08fa165d8.tar.gz linux-stable-556f02699d33c1f40b1b31bd25828ce08fa165d8.tar.bz2 linux-stable-556f02699d33c1f40b1b31bd25828ce08fa165d8.zip |
ACPI: video: check for error while searching for backlight device parent
[ Upstream commit ccd45faf4973746c4f30ea41eec864e5cf191099 ]
If acpi_get_parent() called in acpi_video_dev_register_backlight()
fails, for example, because acpi_ut_acquire_mutex() fails inside
acpi_get_parent), this can lead to incorrect (uninitialized)
acpi_parent handle being passed to acpi_get_pci_dev() for detecting
the parent pci device.
Check acpi_get_parent() result and set parent device only in case of success.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 9661e92c10a9 ("acpi: tie ACPI backlight devices to PCI devices if possible")
Signed-off-by: Nikita Kiryushin <kiryushin@ancud.ru>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/acpi/acpi_video.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index eb7fca6f9444..c22297cce288 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -1797,12 +1797,12 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device) return; count++; - acpi_get_parent(device->dev->handle, &acpi_parent); - - pdev = acpi_get_pci_dev(acpi_parent); - if (pdev) { - parent = &pdev->dev; - pci_dev_put(pdev); + if (ACPI_SUCCESS(acpi_get_parent(device->dev->handle, &acpi_parent))) { + pdev = acpi_get_pci_dev(acpi_parent); + if (pdev) { + parent = &pdev->dev; + pci_dev_put(pdev); + } } memset(&props, 0, sizeof(struct backlight_properties)); |