* [PATCH] thermal/drivers/mediatek/lvts_thermal: Fix a memory leak in an error handling path
@ 2024-01-28 8:38 Christophe JAILLET
2024-01-29 15:53 ` Matthias Brugger
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Christophe JAILLET @ 2024-01-28 8:38 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Matthias Brugger, AngeloGioacchino Del Regno, Balsam CHIHI
Cc: linux-kernel, kernel-janitors, Christophe JAILLET,
Rafael J. Wysocki, linux-pm, linux-arm-kernel, linux-mediatek
If devm_krealloc() fails, then 'efuse' is leaking.
So free it to avoid a leak.
Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/thermal/mediatek/lvts_thermal.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 98d9c80bd4c6..fd4bd650c77a 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -719,8 +719,10 @@ static int lvts_calibration_read(struct device *dev, struct lvts_domain *lvts_td
lvts_td->calib = devm_krealloc(dev, lvts_td->calib,
lvts_td->calib_len + len, GFP_KERNEL);
- if (!lvts_td->calib)
+ if (!lvts_td->calib) {
+ kfree(efuse);
return -ENOMEM;
+ }
memcpy(lvts_td->calib + lvts_td->calib_len, efuse, len);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] thermal/drivers/mediatek/lvts_thermal: Fix a memory leak in an error handling path
2024-01-28 8:38 [PATCH] thermal/drivers/mediatek/lvts_thermal: Fix a memory leak in an error handling path Christophe JAILLET
@ 2024-01-29 15:53 ` Matthias Brugger
2024-01-30 8:36 ` AngeloGioacchino Del Regno
2024-01-30 9:51 ` Daniel Lezcano
2 siblings, 0 replies; 4+ messages in thread
From: Matthias Brugger @ 2024-01-29 15:53 UTC (permalink / raw)
To: Christophe JAILLET, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui,
Lukasz Luba, AngeloGioacchino Del Regno, Balsam CHIHI
Cc: linux-kernel, kernel-janitors, Rafael J. Wysocki, linux-pm,
linux-arm-kernel, linux-mediatek
On 28/01/2024 09:38, Christophe JAILLET wrote:
> If devm_krealloc() fails, then 'efuse' is leaking.
> So free it to avoid a leak.
>
> Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
> drivers/thermal/mediatek/lvts_thermal.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
> index 98d9c80bd4c6..fd4bd650c77a 100644
> --- a/drivers/thermal/mediatek/lvts_thermal.c
> +++ b/drivers/thermal/mediatek/lvts_thermal.c
> @@ -719,8 +719,10 @@ static int lvts_calibration_read(struct device *dev, struct lvts_domain *lvts_td
>
> lvts_td->calib = devm_krealloc(dev, lvts_td->calib,
> lvts_td->calib_len + len, GFP_KERNEL);
> - if (!lvts_td->calib)
> + if (!lvts_td->calib) {
> + kfree(efuse);
> return -ENOMEM;
> + }
>
> memcpy(lvts_td->calib + lvts_td->calib_len, efuse, len);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] thermal/drivers/mediatek/lvts_thermal: Fix a memory leak in an error handling path
2024-01-28 8:38 [PATCH] thermal/drivers/mediatek/lvts_thermal: Fix a memory leak in an error handling path Christophe JAILLET
2024-01-29 15:53 ` Matthias Brugger
@ 2024-01-30 8:36 ` AngeloGioacchino Del Regno
2024-01-30 9:51 ` Daniel Lezcano
2 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-01-30 8:36 UTC (permalink / raw)
To: Christophe JAILLET, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui,
Lukasz Luba, Matthias Brugger, Balsam CHIHI
Cc: linux-kernel, kernel-janitors, Rafael J. Wysocki, linux-pm,
linux-arm-kernel, linux-mediatek
Il 28/01/24 09:38, Christophe JAILLET ha scritto:
> If devm_krealloc() fails, then 'efuse' is leaking.
> So free it to avoid a leak.
>
> Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] thermal/drivers/mediatek/lvts_thermal: Fix a memory leak in an error handling path
2024-01-28 8:38 [PATCH] thermal/drivers/mediatek/lvts_thermal: Fix a memory leak in an error handling path Christophe JAILLET
2024-01-29 15:53 ` Matthias Brugger
2024-01-30 8:36 ` AngeloGioacchino Del Regno
@ 2024-01-30 9:51 ` Daniel Lezcano
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Lezcano @ 2024-01-30 9:51 UTC (permalink / raw)
To: Christophe JAILLET, Rafael J. Wysocki, Zhang Rui, Lukasz Luba,
Matthias Brugger, AngeloGioacchino Del Regno, Balsam CHIHI
Cc: linux-kernel, kernel-janitors, Rafael J. Wysocki, linux-pm,
linux-arm-kernel, linux-mediatek
On 28/01/2024 09:38, Christophe JAILLET wrote:
> If devm_krealloc() fails, then 'efuse' is leaking.
> So free it to avoid a leak.
>
> Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
Applied, thanks
--
<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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-30 9:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-28 8:38 [PATCH] thermal/drivers/mediatek/lvts_thermal: Fix a memory leak in an error handling path Christophe JAILLET
2024-01-29 15:53 ` Matthias Brugger
2024-01-30 8:36 ` AngeloGioacchino Del Regno
2024-01-30 9:51 ` Daniel Lezcano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).