From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DDC63C0D; Tue, 23 Jan 2024 00:03:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705968186; cv=none; b=ZtT9KH/UNtdq58WSDOIPNevee1nLxwLQaG+rGPUMQofyrZQsWQI2BEg3QjOBHW2Hfiww56YYB8v3ROyqIlmrcgdP95KQ1Kzv9qJT3iTaCtqEFNBxYxrRTlvHcpXhnAnidzQQm5y33Wotshdc6M2QxHMKsidK7KDb4+rIG1mIodg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705968186; c=relaxed/simple; bh=e4Ki2jnpkR2BcMdjBLcX9smAyR4DfJM4TtTjgmLlIrA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LrlKFCmkO7Sz+2EFvMfV255DojJuLYUMK7w/LlKYiUgYg29kh9Tj9bsXvzvu4v7wLasLnX01AU7asDdpwyQwcwSyA2hCj4spBUGTYyevgQzT0XVytwghpn6XjTOeZrow8p+XVs5R1Y9LNHOphmwydnZ0Ylm47OVyCJyJ3jjgjnI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Qnf0QKe5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Qnf0QKe5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29EEDC433F1; Tue, 23 Jan 2024 00:03:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705968186; bh=e4Ki2jnpkR2BcMdjBLcX9smAyR4DfJM4TtTjgmLlIrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qnf0QKe5g9X5IDMQDRluCHQd2/pP01KM3bFBr3JKF9n/C0Oxnp8GV12ZCp1P56S7O 10WigPacoz7BBlpGnWcRTqZv3nzsU/4VIVYl87Zey2lkJ5kMmOKFdsqNxanFZRdY1G fK1RLu0G8nHwxIOhArlslMXvzAYlJPFEaoVxCQMs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nikita Kiryushin , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 4.19 038/148] ACPI: video: check for error while searching for backlight device parent Date: Mon, 22 Jan 2024 15:56:34 -0800 Message-ID: <20240122235713.950185904@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122235712.442097787@linuxfoundation.org> References: <20240122235712.442097787@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nikita Kiryushin [ 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 Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- 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 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)); -- 2.43.0