提交 d44616c6 编写于 作者: D Daniel Lezcano

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: 58483761 ("thermal/drivers/core: Use a char pointer for the cooling device name")
Reported-by: Nkernel test robot <lkp@intel.com>
Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20210319202257.890848-1-daniel.lezcano@linaro.org
上级 ef6e01af
...@@ -1017,6 +1017,7 @@ __thermal_cooling_device_register(struct device_node *np, ...@@ -1017,6 +1017,7 @@ __thermal_cooling_device_register(struct device_node *np,
out_ida_remove: out_ida_remove:
ida_simple_remove(&thermal_cdev_ida, cdev->id); ida_simple_remove(&thermal_cdev_ida, cdev->id);
out_kfree_cdev: out_kfree_cdev:
kfree(cdev);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册