public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI: platform_profile: Fix memory leak in profile_class_is_visible()
@ 2025-02-12 19:30 Kurt Borja
  2025-02-15  2:18 ` Mark Pearson
  0 siblings, 1 reply; 5+ messages in thread
From: Kurt Borja @ 2025-02-12 19:30 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Len Brown, Ilpo Järvinen, Mark Pearson, Mario Limonciello,
	Armin Wolf, Kurt Borja, Gergo Koteles, linux-acpi, linux-kernel

If class_find_device() finds a device it's reference count is
incremented. Call put_device() to drop this reference before returning.

Fixes: 77be5cacb2c2 ("ACPI: platform_profile: Create class for ACPI platform profile")
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
 drivers/acpi/platform_profile.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index fc92e43d0fe9..2ad53cc6aae5 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -417,8 +417,14 @@ static int profile_class_registered(struct device *dev, const void *data)
 
 static umode_t profile_class_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
 {
-	if (!class_find_device(&platform_profile_class, NULL, NULL, profile_class_registered))
+	struct device *dev;
+
+	dev = class_find_device(&platform_profile_class, NULL, NULL, profile_class_registered);
+	if (!dev)
 		return 0;
+
+	put_device(dev);
+
 	return attr->mode;
 }
 

base-commit: 3e3e377dd1f300bbdd230533686ce9c9f4f8a90d
-- 
2.48.1


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

end of thread, other threads:[~2025-02-18 18:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-12 19:30 [PATCH] ACPI: platform_profile: Fix memory leak in profile_class_is_visible() Kurt Borja
2025-02-15  2:18 ` Mark Pearson
2025-02-18 18:07   ` Rafael J. Wysocki
2025-02-18 18:18     ` Kurt Borja
2025-02-18 18:27       ` Rafael J. Wysocki

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