Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.

Commit a68aed3

Browse files
rohith2xssysopenci
authored andcommitted
Adding Mutex Lock to Avoid Race Condition
The following fields encountered a race condition. Adding a `mutex_lock` in the critical section resolves the issue: - `drv->event_thread` - `drv->in_cleanup` **Tests:** - Android boot up success - WiFi/Hotspot ON/OFF success - Connect WiFi to network success Tracked-On: Adding Mutex Lock to Avoid Race Condition The following fields encountered a race condition. Adding a `mutex_lock` in the critical section resolves the issue: - `drv->event_thread` - `drv->in_cleanup` **Tests:** - Android boot up success - WiFi/Hotspot ON/OFF success - Connect WiFi to network success merging bsp diff patches Tracked-On: OAM-130073 Signed-off-by: rohith2xs <rohith2x.s@intel.com>
1 parent 32fd183 commit a68aed3

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

lib/driver_if.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2005,11 +2005,14 @@ void driver_if_events(void *handle)
20052005
if (DRV_NOT_INIT(drv, __func__))
20062006
return;
20072007

2008+
MUTEX_LOCK(&drv->sync);
20082009
if (drv->event_thread) {
2010+
MUTEX_UNLOCK(&drv->sync);
20092011
hal_printf(MSG_ERROR, "%s called when already on event loop",
20102012
__func__);
20112013
return;
20122014
}
2015+
MUTEX_UNLOCK(&drv->sync);
20132016

20142017
if (MUTEX_LOCK(&drv->sync))
20152018
return;
@@ -2041,7 +2044,13 @@ void driver_if_events(void *handle)
20412044
hal_printf(MSG_DEBUG, "Starting event loop tid=%u",
20422045
drv->event_thread);
20432046

2044-
while (!drv->in_cleanup) {
2047+
while (! [&]()-> bool {
2048+
MUTEX_LOCK(&drv->sync);
2049+
bool ret = drv->in_cleanup;
2050+
MUTEX_UNLOCK(&drv->sync);
2051+
return ret;
2052+
}()
2053+
) {
20452054
pfd[1].fd = drv->nl_rtt ? nl_socket_get_fd(drv->nl_rtt) : -1;
20462055
int res = ppoll(pfd, NFDS, &ts, &sms);
20472056
hal_printf(MSG_ERROR, "Out of event poll");

0 commit comments

Comments
 (0)