diff options
author | Dongwoo Lee <dwoo08.lee@samsung.com> | 2019-04-30 13:11:39 +0900 |
---|---|---|
committer | Dongwoo Lee <dwoo08.lee@samsung.com> | 2019-05-27 17:15:49 +0900 |
commit | 3ec20dd0ab16e212ad4bcf64fa04602287e30643 (patch) | |
tree | 244a27197729a84415e50a974fc96105af5e5873 | |
parent | 79ab724716daa0aa08d17e123f53ccdeab4ecf71 (diff) | |
download | pass-3ec20dd0ab16e212ad4bcf64fa04602287e30643.tar.gz pass-3ec20dd0ab16e212ad4bcf64fa04602287e30643.tar.bz2 pass-3ec20dd0ab16e212ad4bcf64fa04602287e30643.zip |
pass: thermal: Prevent memory leakage
To prevent memory leakage, free allocated memory on error case.
Change-Id: If0c94bc23e47eafff594afb435b909b544708ac3
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
-rw-r--r-- | src/thermal/thermal.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/thermal/thermal.c b/src/thermal/thermal.c index cf823f5..3937be1 100644 --- a/src/thermal/thermal.c +++ b/src/thermal/thermal.c @@ -103,13 +103,18 @@ static int thermal_init_done(void *data, void *user_data) 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; } |