e_devicemgr: fix concurrent data access issue 17/303217/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Thu, 21 Dec 2023 09:26:07 +0000 (18:26 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 21 Dec 2023 10:46:03 +0000 (19:46 +0900)
Unlocking &e_devicemgr->device_list_mutex.
dev might now be unreliable because other threads can now change the data that it depends on.

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

index 2c20562..e8bad06 100644 (file)
@@ -288,9 +288,10 @@ _e_devicemgr_input_device_del(const char *name, const char *identifier, const ch
             (!strcmp(dev->identifier, identifier)))
           break;
      }
-   g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
+
    if (!dev)
      {
+        g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
         return;
      }
 
@@ -301,9 +302,7 @@ _e_devicemgr_input_device_del(const char *name, const char *identifier, const ch
    if (dev->identifier) eina_stringshare_del(dev->identifier);
    if (dev->seat_name) eina_stringshare_del(dev->seat_name);
 
-   g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
    e_devicemgr->device_list = eina_list_remove(e_devicemgr->device_list, dev);
-   g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
 
    if (e_devicemgr->last_device_ptr == dev)
      e_devicemgr->last_device_ptr = NULL;
@@ -317,6 +316,8 @@ _e_devicemgr_input_device_del(const char *name, const char *identifier, const ch
      atomic_store(&e_devicemgr->last_device_kbd, NULL);
 
    E_FREE(dev);
+
+   g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
 }
 
 static void