thermal/core: Fix memory leak in the error path
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Fri, 19 Mar 2021 20:22:57 +0000 (21:22 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:21:30 +0000 (10:21 +0200)
commit54cdc10ac7184f2159a4f5658b497e90244d1516
treec0ce5001c857af723679ef92d807ace58e2e4351
parentb132abaa6515e14e0db292389c25007d666e1925
thermal/core: Fix memory leak in the error path

commit d44616c6cc3e35eea03ecfe9040edfa2b486a059 upstream.

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 <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20210319202257.890848-1-daniel.lezcano@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/thermal/thermal_core.c