From: Jie Zhan <zhanjie9@hisilicon.com>
To: Malaya Kumar Rout <malayarout91@gmail.com>,
<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>,
<linux-pm@vger.kernel.org>
Cc: <mrout@redhat.com>, <skhan@linuxfoundation.org>,
<me@brighamcampbell.com>, MyungJoo Ham <myungjoo.ham@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
Chanwoo Choi <cw00.choi@samsung.com>,
Kant Fan <kant@allwinnertech.com>
Subject: Re: [PATCH] PM / devfreq: userspace: Fix memory leak in userspace_init()
Date: Tue, 28 Jul 2026 14:31:22 +0800 [thread overview]
Message-ID: <511c7f13-3344-44bf-a960-044fc2401789@hisilicon.com> (raw)
In-Reply-To: <20260704163238.115819-1-malayarout91@gmail.com>
On 7/5/2026 12:32 AM, Malaya Kumar Rout wrote:
> 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);
> +
Redundant blank line. Otherwise,
Reviewed-by: Jie Zhan <zhanjie9@hisilicon.com>
BTW, this function can be slightly cleaned up, e.g. the 'goto' statement
can be removed.
> + if (err) {
> + kfree(data);
> + devfreq->governor_data = NULL;
> + }
> +
> out:
> return err;
> }
next prev parent reply other threads:[~2026-07-28 6:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-04 16:32 [PATCH] PM / devfreq: userspace: Fix memory leak in userspace_init() Malaya Kumar Rout
2026-07-24 6:17 ` malaya kumar rout
2026-07-28 6:31 ` Jie Zhan [this message]
2026-07-29 13:35 ` [PATCH v2] " Malaya Kumar Rout
2026-07-30 12:51 ` Jie Zhan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=511c7f13-3344-44bf-a960-044fc2401789@hisilicon.com \
--to=zhanjie9@hisilicon.com \
--cc=cw00.choi@samsung.com \
--cc=kant@allwinnertech.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=malayarout91@gmail.com \
--cc=me@brighamcampbell.com \
--cc=mrout@redhat.com \
--cc=myungjoo.ham@samsung.com \
--cc=skhan@linuxfoundation.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox