[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2d04feea-c568-5ff8-019b-119b824e8a0f@huawei.com>
Date: Thu, 7 Nov 2024 09:30:12 +0800
From: Jinjie Ruan <ruanjinjie@...wei.com>
To: <daniel.lezcano@...nel.org>, <rafael@...nel.org>,
<linux-pm@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] powercap: dtpm_devfreq: Fix possible memory leak in
__dtpm_devfreq_setup()
Gentle ping.
On 2024/10/26 16:25, Jinjie Ruan wrote:
> If dev_pm_qos_add_request() fails, dtpm_devfreq will fail
> to free, which cause the memory leak, add a new goto label
> to free it.
>
> Fixes: e44655617317 ("powercap/drivers/dtpm: Add dtpm devfreq with energy model support")
> Signed-off-by: Jinjie Ruan <ruanjinjie@...wei.com>
> ---
> drivers/powercap/dtpm_devfreq.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/powercap/dtpm_devfreq.c b/drivers/powercap/dtpm_devfreq.c
> index d1dff6ccab12..85b6982901d1 100644
> --- a/drivers/powercap/dtpm_devfreq.c
> +++ b/drivers/powercap/dtpm_devfreq.c
> @@ -171,8 +171,7 @@ static int __dtpm_devfreq_setup(struct devfreq *devfreq, struct dtpm *parent)
> ret = dtpm_register(dev_name(dev), &dtpm_devfreq->dtpm, parent);
> if (ret) {
> pr_err("Failed to register '%s': %d\n", dev_name(dev), ret);
> - kfree(dtpm_devfreq);
> - return ret;
> + goto out_dtpm_free;
> }
>
> ret = dev_pm_qos_add_request(dev, &dtpm_devfreq->qos_req,
> @@ -190,6 +189,8 @@ static int __dtpm_devfreq_setup(struct devfreq *devfreq, struct dtpm *parent)
> out_dtpm_unregister:
> dtpm_unregister(&dtpm_devfreq->dtpm);
>
> +out_dtpm_free:
> + kfree(dtpm_devfreq);
> return ret;
> }
>
Powered by blists - more mailing lists