From patchwork Thu Nov 9 13:49:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Kiryushin X-Patchwork-Id: 163402 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp443104vqs; Thu, 9 Nov 2023 05:49:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQ5/89USs0mm2FytRgOOH4H0Z9JoRDKsmUTOENteRythRpmxSoNHYXjF1n+6xn/4SWFH6r X-Received: by 2002:a05:6a20:c189:b0:161:2df0:eadf with SMTP id bg9-20020a056a20c18900b001612df0eadfmr5688880pzb.24.1699537781219; Thu, 09 Nov 2023 05:49:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699537781; cv=none; d=google.com; s=arc-20160816; b=XzJvyDJbE8ecxvn2jPh6ZFvnia8WKO3UBgGo6aVpZ883OqPCtk7dRbHQGT8P/OCzDC gLuo22aFLw9/rn44Y4BR+2LOwnZfCWvb8Rl1Kh9uXmgufxPcOD86hMWJePtPX+JJaGpg OM4JahFof5HwpZHXMf3xdh9z/dcYSy24WWceYFRredI6sDbNsUVRwBHfsoC4/A7cs96S 8GjH9208mpp1C3VtRqT0IH0sJg/DMhV9wWWqZCqqYLQ3IFZOeDkG2tKRIF24hJtbq0Vc zGxdJNCeNkpcAKJf5Yc2aLyn5QribCCL8QNz40m0NMW/MA2OYqQLWVS7UN2EAC69ruIG ulsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language:cc:to :subject:from:user-agent:mime-version:date:message-id; bh=0oNASf5IcsTEGEDJw+WbrO/eNIRzWmeewkGtrvEi6lo=; fh=uBxAu0vEmTsG+E9KY4D5F4c+piFUjqgvbKsHrAfmAuA=; b=h6+PprwWTmZcv3+l2cEgZMZDqe47ZZriES/QhOC1ABHqlYhW6VLxG8RHh5xdzDpOYh 2MjuJeYg9wehyhaNe0xDfd7HEWG5sZ/vfmFLzVzSD5g++J4o9SGsQlx4ka+cE0hHGBBZ G02hZ3HkZgnj+zZQC+y/dkXUk7L+2mmFSvg20Wi17kYVWUh4Q8D+5Li61qrSBUZAWxMV KqkDb7U05f1JgY0BYtn0Ow8ImMUTIJPKpbBKcUBsa22Vjfn90Vz+ebpyrhVmwoEAX+M/ COD8pekiXvIcbEMB0WhtCPbzto4iLYtmlYh2qLDcFVpDplfelOqLH2z8uHPxET2mxQ+s xitw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e17-20020a056a001a9100b006c0f03b2466si15918807pfv.53.2023.11.09.05.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 05:49:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E82C18027F10; Thu, 9 Nov 2023 05:49:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234117AbjKINtg (ORCPT + 32 others); Thu, 9 Nov 2023 08:49:36 -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 X-MS-Exchange-Organization-SCL: -1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 09 Nov 2023 05:49:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782094528484006961 X-GMAIL-MSGID: 1782094528484006961 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 possible") Signed-off-by: Nikita Kiryushin --- drivers/acpi/acpi_video.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 2.34.1 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 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)); --