aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKurt Borja <[email protected]>2025-02-12 19:30:58 +0000
committerRafael J. Wysocki <[email protected]>2025-02-18 19:03:37 +0000
commitd403120cb9d4787b283ea202b2162f459d18fe9d (patch)
tree776cd9f51133bdf3cb2fcf509dda6d810d30eb89
parentLinux 6.14-rc3 (diff)
downloadkernel-d403120cb9d4787b283ea202b2162f459d18fe9d.tar.gz
kernel-d403120cb9d4787b283ea202b2162f459d18fe9d.zip
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: 77be5cacb2c2 ("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]>
-rw-r--r--drivers/acpi/platform_profile.c8
1 files changed, 7 insertions, 1 deletions
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;
}