* [PATCH] PM / devfreq: userspace: Fix memory leak in userspace_init()
@ 2026-07-04 16:32 Malaya Kumar Rout
0 siblings, 0 replies; only message in thread
From: Malaya Kumar Rout @ 2026-07-04 16:32 UTC (permalink / raw)
To: linux-kernel, stable, linux-pm
Cc: mrout, skhan, me, Malaya Kumar Rout, MyungJoo Ham, Kyungmin Park,
Chanwoo Choi, Kant Fan
Fix a memory leak in the userspace_init() function where allocated
memory is not freed when sysfs_create_group() fails.
When sysfs_create_group() fails, the function returns without freeing
the memory allocated for 'data', leading to a memory leak. This patch
adds proper error handling to free the allocated memory and reset
governor_data to NULL on failure.
Fixes: 5fdded844892 ("PM/devfreq: governor: Add a private governor_data for governor")
Signed-off-by: Malaya Kumar Rout <malayarout91@gmail.com>
---
drivers/devfreq/governor_userspace.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/devfreq/governor_userspace.c b/drivers/devfreq/governor_userspace.c
index 3906ebedbae8..b9fbcacdfba1 100644
--- a/drivers/devfreq/governor_userspace.c
+++ b/drivers/devfreq/governor_userspace.c
@@ -97,6 +97,12 @@ static int userspace_init(struct devfreq *devfreq)
devfreq->governor_data = data;
err = sysfs_create_group(&devfreq->dev.kobj, &dev_attr_group);
+
+ if (err) {
+ kfree(data);
+ devfreq->governor_data = NULL;
+ }
+
out:
return err;
}
--
2.54.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-04 16:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-04 16:32 [PATCH] PM / devfreq: userspace: Fix memory leak in userspace_init() Malaya Kumar Rout
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox