e_comp_wl_input: add missing mutex for xkb.state variable 44/303644/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Tue, 2 Jan 2024 03:01:35 +0000 (12:01 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 3 Jan 2024 04:19:03 +0000 (13:19 +0900)
missing_lock: Accessing e_comp_wl->xkb.state without holding lock _E_Comp_Wl_Data.xkb.state_mutex.
Elsewhere, _E_Comp_Wl_Data.xkb.state is written to with _E_Comp_Wl_Data.xkb.state_mutex held 5 out of 5 times.

Change-Id: Id85216287e5644f276fbeb80e615bd5df7816e1f
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/bin/e_comp_wl_input.c

index 598a92d..195f517 100644 (file)
@@ -2111,13 +2111,18 @@ e_comp_wl_input_keymap_keycode_to_keyname(int keycode)
 
    EINA_SAFETY_ON_FALSE_RETURN_VAL(8 <= keycode, NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, NULL);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl->xkb.state, NULL);
-
    g_mutex_lock(&e_comp_wl->xkb.state_mutex);
+   if (!e_comp_wl->xkb.state)
+     {
+        g_mutex_unlock(&e_comp_wl->xkb.state_mutex);
+        return NULL;
+     }
+
    state = e_comp_wl->xkb.state;
-   g_mutex_unlock(&e_comp_wl->xkb.state_mutex);
 
    sym = xkb_state_key_get_one_sym(state, keycode);
+   g_mutex_unlock(&e_comp_wl->xkb.state_mutex);
+
    if (sym == XKB_KEY_NoSymbol)
      {
         snprintf(name, sizeof(name), "Keycode-%u", keycode);
@@ -2132,4 +2137,4 @@ E_API Eina_Bool
 e_comp_wl_input_pointer_constraint_activated_get(void)
 {
    return e_comp_wl->ptr_constraints.activated;
-}
\ No newline at end of file
+}