pass: rescon: Add missing lock for scenario_level_list 44/259944/1 accepted/tizen/unified/20210617.124845 submit/tizen/20210617.021704
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 17 Jun 2021 01:59:01 +0000 (10:59 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Thu, 17 Jun 2021 01:59:50 +0000 (10:59 +0900)
scenario_level_list variables should be protected by mutext.
So thath add missing lock for scenario_level_list

Change-Id: Ib4590fd3b76e3e9f6953234cbb1f7b21c7af7520
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/pass/pass-rescon.c

index cb934e2..79d3a1a 100644 (file)
@@ -516,9 +516,12 @@ int pass_rescon_init(struct pass_resource *res)
        res->config_data.default_max_level = rescon->max_level;
 
        /* Initialize g_list of scenario_level */
-       rescon->scenario_level_list = NULL;
        g_mutex_init(&rescon->scenario_level_mutex);
 
+       g_mutex_lock(&rescon->scenario_level_mutex);
+       rescon->scenario_level_list = NULL;
+       g_mutex_unlock(&rescon->scenario_level_mutex);
+
        /*
         * Save the current data of h/w resource. The saved data
         * will be used for restoring the h/w resource on exit().
@@ -592,8 +595,11 @@ int pass_rescon_exit(struct pass_resource *res)
        rescon->init_level = 0;
 
        /* Free g_list of scenario_level */
+       g_mutex_lock(&rescon->scenario_level_mutex);
        g_list_free(rescon->scenario_level_list);
        rescon->scenario_level_list = NULL;
+       g_mutex_unlock(&rescon->scenario_level_mutex);
+
        g_mutex_clear(&rescon->scenario_level_mutex);
 
        rescon->state = PASS_OFF;