From: Dongwoo Lee Date: Thu, 7 Mar 2024 06:41:29 +0000 (+0900) Subject: lib: resource-monitor: Fix missing mutual exclusion X-Git-Tag: accepted/tizen/unified/20240308.174124~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d6af8ee66ad32a35011aaaf5b3ce02608c96e7ff;p=platform%2Fcore%2Fsystem%2Fpass.git lib: resource-monitor: Fix missing mutual exclusion Since find_client_by_id() walks g_pass_resource_monitor_client_head list which is prevented by critical section, it should be mutually exclusive, thus mutex lock/unlock is added to former/later of loop. Change-Id: I6ea2dad42ff9dd08dec331db7ea4c9de550da618 Signed-off-by: Dongwoo Lee --- diff --git a/lib/resource-monitor/resource-monitor.c b/lib/resource-monitor/resource-monitor.c index 75bff22..ccf384c 100644 --- a/lib/resource-monitor/resource-monitor.c +++ b/lib/resource-monitor/resource-monitor.c @@ -89,13 +89,17 @@ static struct pass_resource_monitor_client *find_client_by_id(int id) struct pass_resource_monitor_client *client; GList *node; + g_mutex_lock(&g_mutex); for (node = g_pass_resource_monitor_client_head; node != NULL; node = node->next) { client = node->data; - if (client->id == id) + if (client->id == id) { + g_mutex_unlock(&g_mutex); return client; + } } + g_mutex_unlock(&g_mutex); return NULL; }