To prevent memory leakage, free allocated memory on error case.
Change-Id: If0c94bc23e47eafff594afb435b909b544708ac3
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
ret = thermal_get_scenario(THERMAL_CONF_PATH, g_thermal);
if (ret < 0) {
_E("failed to get Thermal Monitor scenario\n");
+ free(g_thermal);
+ g_thermal = NULL;
return ret;
}
if (!g_thermal->support || g_thermal->num <= 0) {
ret = thermal_put_scenario(g_thermal);
- if (ret < 0)
- _E("failed to pet Thermal Monitor scenario\n");
+ if (ret < 0) {
+ _E("failed to put Thermal Monitor scenario\n");
+ free(g_thermal);
+ g_thermal = NULL;
+ }
return ret;
}