Skip to content

Commit

Permalink
ACPI: platform_profile: Fix memory leak in profile_class_is_visible()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
kuu-rt authored and rafaeljw committed Feb 18, 2025
1 parent 0ad2507 commit d403120
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/acpi/platform_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit d403120

Please sign in to comment.