public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/3] ACPI: video: Fix refcounting in apple_gmux_backlight_present()
@ 2023-01-23 17:10 Andy Shevchenko
  2023-01-23 17:10 ` [PATCH v1 2/3] ACPI: utils: Add acpi_get_first_match_physical_node() Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Andy Shevchenko @ 2023-01-23 17:10 UTC (permalink / raw)
  To: Andy Shevchenko, Hans de Goede, Rafael J. Wysocki, linux-acpi,
	linux-kernel, acpica-devel
  Cc: Rafael J. Wysocki, Len Brown, Robert Moore

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@linux.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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-01-25 15:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-23 17:10 [PATCH v1 1/3] ACPI: video: Fix refcounting in apple_gmux_backlight_present() Andy Shevchenko
2023-01-23 17:10 ` [PATCH v1 2/3] ACPI: utils: Add acpi_get_first_match_physical_node() Andy Shevchenko
2023-01-25 15:21   ` Andy Shevchenko
2023-01-23 17:10 ` [PATCH v1 3/3] ACPI: video: Switch to use acpi_get_first_match_physical_node() Andy Shevchenko
2023-01-23 17:46 ` [PATCH v1 1/3] ACPI: video: Fix refcounting in apple_gmux_backlight_present() Hans de Goede
2023-01-23 18:18   ` Andy Shevchenko
2023-01-23 19:24     ` Rafael J. Wysocki
2023-01-24  9:04       ` Andy Shevchenko
2023-01-23 22:10     ` Hans de Goede
2023-01-24  9:05       ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox