Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal/drivers/mediatek/lvts_thermal: Fix a memory leak in an error handling path

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>
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

authored by

Christophe JAILLET and committed by
Daniel Lezcano
ca93bf60 dcb497ec

+3 -1
+3 -1
drivers/thermal/mediatek/lvts_thermal.c
··· 719 719 720 720 lvts_td->calib = devm_krealloc(dev, lvts_td->calib, 721 721 lvts_td->calib_len + len, GFP_KERNEL); 722 - if (!lvts_td->calib) 722 + if (!lvts_td->calib) { 723 + kfree(efuse); 723 724 return -ENOMEM; 725 + } 724 726 725 727 memcpy(lvts_td->calib + lvts_td->calib_len, efuse, len); 726 728