Skip to content

Commit d403120

Browse files
kuu-rtrafaeljw
authored andcommitted
ACPI: platform_profile: Fix memory leak in profile_class_is_visible()
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 <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 0ad2507 commit d403120

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
@@ -417,8 +417,14 @@ static int profile_class_registered(struct device *dev, const void *data)
417417

418418
static umode_t profile_class_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
419419
{
420-
if (!class_find_device(&platform_profile_class, NULL, NULL, profile_class_registered))
420+
struct device *dev;
421+
422+
dev = class_find_device(&platform_profile_class, NULL, NULL, profile_class_registered);
423+
if (!dev)
421424
return 0;
425+
426+
put_device(dev);
427+
422428
return attr->mode;
423429
}
424430

0 commit comments

Comments
 (0)