pass: thermal: Prevent memory leakage 90/206790/2
authorDongwoo Lee <dwoo08.lee@samsung.com>
Tue, 30 Apr 2019 04:11:39 +0000 (13:11 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Mon, 27 May 2019 08:15:49 +0000 (17:15 +0900)
To prevent memory leakage, free allocated memory on error case.

Change-Id: If0c94bc23e47eafff594afb435b909b544708ac3
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
src/thermal/thermal.c

index cf823f5ee3f1fa9aa2c3d9470410fb5d4609105c..3937be176c4a31020f08011fee509f3bae73c075 100644 (file)
@@ -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;
        }