lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230123171006.58274-1-andriy.shevchenko@linux.intel.com>
Date:   Mon, 23 Jan 2023 19:10:04 +0200
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Hans de Goede <hdegoede@...hat.com>,
        "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
        linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org,
        acpica-devel@...ts.linuxfoundation.org
Cc:     "Rafael J. Wysocki" <rafael@...nel.org>,
        Len Brown <lenb@...nel.org>,
        Robert Moore <robert.moore@...el.com>
Subject: [PATCH v1 1/3] ACPI: video: Fix refcounting in apple_gmux_backlight_present()

acpi_dev_get_first_match_dev() gets ACPI device with the bumped
refcount. The caller must drop it when it's done.

Fix ACPI device refcounting in apple_gmux_backlight_present().

Fixes: 3cf3b7f012f3 ("ACPI: video: Fix Apple GMUX backlight detection")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
 drivers/acpi/video_detect.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index 65cec7bb6d96..0ccde0d4c527 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -114,12 +114,14 @@ static bool apple_gmux_backlight_present(void)
 {
 	struct acpi_device *adev;
 	struct device *dev;
+	bool ret;
 
 	adev = acpi_dev_get_first_match_dev(GMUX_ACPI_HID, NULL, -1);
 	if (!adev)
 		return false;
 
-	dev = acpi_get_first_physical_node(adev);
+	dev = get_device(acpi_get_first_physical_node(adev));
+	acpi_dev_put(adev);
 	if (!dev)
 		return false;
 
@@ -127,7 +129,9 @@ static bool apple_gmux_backlight_present(void)
 	 * drivers/platform/x86/apple-gmux.c only supports old style
 	 * Apple GMUX with an IO-resource.
 	 */
-	return pnp_get_resource(to_pnp_dev(dev), IORESOURCE_IO, 0) != NULL;
+	ret = pnp_get_resource(to_pnp_dev(dev), IORESOURCE_IO, 0) != NULL;
+	put_device(dev);
+	return ret;
 }
 
 /* Force to use vendor driver when the ACPI device is known to be
-- 
2.39.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ