From: Daniel Lezcano Date: Fri, 19 Mar 2021 20:22:57 +0000 (+0100) Subject: thermal/core: Fix memory leak in the error path X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=d44616c6cc3e35eea03ecfe9040edfa2b486a059;p=linux.git thermal/core: Fix memory leak in the error path Fix the following error: smatch warnings: drivers/thermal/thermal_core.c:1020 __thermal_cooling_device_register() warn: possible memory leak of 'cdev' by freeing the cdev when exiting the function in the error path. Fixes: 584837618100 ("thermal/drivers/core: Use a char pointer for the cooling device name") Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20210319202257.890848-1-daniel.lezcano@linaro.org --- diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index c8d4010940ef2..3566fd291399f 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1017,6 +1017,7 @@ out_kfree_type: out_ida_remove: ida_simple_remove(&thermal_cdev_ida, cdev->id); out_kfree_cdev: + kfree(cdev); return ERR_PTR(ret); }