[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b40dc34b-85b2-4d7a-e28e-7beea4bb29f6@linaro.org>
Date: Thu, 12 Nov 2020 12:22:22 +0100
From: Daniel Lezcano <daniel.lezcano@...aro.org>
To: Bernard <bernard@...o.com>, Zhang Rui <rui.zhang@...el.com>,
Amit Kucheria <amitk@...nel.org>, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: opensource.kernel@...o.com
Subject: Re: [Resend][PATCH] drivers/thermal: fix potential memleak in error
branch
On 10/11/2020 09:10, Bernard wrote:
> Function __thermal_cooling_device_register, when device_register
> failed, cdev is not free after error value return, this may
> bring in potential memleak.
>
> Signed-off-by: Bernard Zhao <bernard@...o.com>
> ---
> drivers/thermal/thermal_core.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 3d1e0033bf3e..e4bee15dfa1f 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -1125,6 +1125,7 @@ __thermal_cooling_device_register(struct device_node *np,
> if (result) {
> ida_simple_remove(&thermal_cdev_ida, cdev->id);
> put_device(&cdev->device);
> + kfree(cdev);
> return ERR_PTR(result);
> }
Please fix the function with the proper error path and the labels.
Thanks
-- Daniel
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
Powered by blists - more mailing lists