Skip to content

Commit

Permalink
thermal/drivers/mediatek/lvts_thermal: Fix a memory leak in an error …
Browse files Browse the repository at this point in the history
…handling path

[ Upstream commit ca93bf6 ]

If devm_krealloc() fails, then 'efuse' is leaking.
So free it to avoid a leak.

Fixes: f5f633b ("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>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/481d345233862d58c3c305855a93d0dbc2bbae7e.1706431063.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
tititiou36 authored and Sasha Levin committed Mar 26, 2024
1 parent 13eccd7 commit 2db869d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/thermal/mediatek/lvts_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,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);

Expand Down

0 comments on commit 2db869d

Please sign in to comment.