Skip to content

Commit efb504e

Browse files
committed
ACPI: platform_profile: Fix memory leak in profile_class_is_visible()
JIRA: https://issues.redhat.com/browse/RHEL-89362 commit d403120 Author: Kurt Borja <kuurtb@gmail.com> Date: Tue, 18 Feb 2025 20:03:37 +0000 If class_find_device() finds a device, it's reference count is incremented. Call put_device() to drop this reference before returning. Fixes: 77be5ca ("ACPI: platform_profile: Create class for ACPI platform profile") Signed-off-by: Kurt Borja <kuurtb@gmail.com> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca> Link: https://patch.msgid.link/20250212193058.32110-1-kuurtb@gmail.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
1 parent 14c6998 commit efb504e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/acpi/platform_profile.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,14 @@ static int profile_class_registered(struct device *dev, const void *data)
458458

459459
static umode_t profile_class_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
460460
{
461-
if (!class_find_device(&platform_profile_class, NULL, NULL, profile_class_registered))
461+
struct device *dev;
462+
463+
dev = class_find_device(&platform_profile_class, NULL, NULL, profile_class_registered);
464+
if (!dev)
462465
return 0;
466+
467+
put_device(dev);
468+
463469
return attr->mode;
464470
}
465471

0 commit comments

Comments
 (0)