From nobody Wed Dec 17 03:48:15 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22B4BC4332F for ; Thu, 9 Nov 2023 13:49:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234172AbjKINth (ORCPT ); Thu, 9 Nov 2023 08:49:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232167AbjKINtf (ORCPT ); Thu, 9 Nov 2023 08:49:35 -0500 Received: from relay163.nicmail.ru (relay163.nicmail.ru [91.189.117.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16E1930CF for ; Thu, 9 Nov 2023 05:49:31 -0800 (PST) Received: from [10.28.138.148] (port=33836 helo=[192.168.95.111]) by relay.hosting.mail.nic.ru with esmtp (Exim 5.55) (envelope-from ) id 1r15PS-0005CE-BH; Thu, 09 Nov 2023 16:49:26 +0300 Received: from [87.245.155.195] (account kiryushin@ancud.ru HELO [192.168.95.111]) by incarp1101.mail.hosting.nic.ru (Exim 5.55) with id 1r15PS-00E7MJ-1K; Thu, 09 Nov 2023 16:49:26 +0300 Message-ID: <262a7526-9e0a-4688-85b4-8546a6580ad0@ancud.ru> Date: Thu, 9 Nov 2023 16:49:25 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Nikita Kiryushin Subject: [PATCH] ACPI: video: check for error while searching for backlit device parent To: "Rafael J. Wysocki" Cc: Len Brown , Matthew Garrett , Andrew Morton , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-MS-Exchange-Organization-SCL: -1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8"; format="flowed" If acpi_get_parent called in acpi_video_dev_register_backlight fails (for example, acpi_ut_acquire_mutex fails inside acpi_get_parent), this can lead to incorrect (uninitialized) acpi_parent handler being passed to acpi_get_pci_dev for detecting 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=20 possible") Signed-off-by: Nikita Kiryushin --- drivers/acpi/acpi_video.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 0b7a01f38b65..1d550887349a 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -1717,12 +1717,12 @@ static void=20 acpi_video_dev_register_backlight(struct acpi_video_device *device) return; count++; - acpi_get_parent(device->dev->handle, &acpi_parent); - - pdev =3D acpi_get_pci_dev(acpi_parent); - if (pdev) { - parent =3D &pdev->dev; - pci_dev_put(pdev); + if (ACPI_SUCCESS(acpi_get_parent(device->dev->handle, &acpi_parent))) { + pdev =3D acpi_get_pci_dev(acpi_parent); + if (pdev) { + parent =3D &pdev->dev; + pci_dev_put(pdev); + } } memset(&props, 0, sizeof(struct backlight_properties)); --=20 2.34.1