OSDN Git Service

Fix a deadlock in wifi_cleanup
authorVinit Deshpande <vinitd@google.com>
Fri, 5 Jun 2015 03:01:03 +0000 (20:01 -0700)
committerVinit Deshpande <vinitd@google.com>
Fri, 5 Jun 2015 03:01:03 +0000 (20:01 -0700)
pthread_mutex isn't re-entrant; and results in a hang
if called second time from the same thread. This change
ensures that it is locked only once.

Bug: 21627368
Change-Id: I9c28c1df240316c2a7eafdefa990b9582bc05a9a

bcmdhd/wifi_hal/wifi_hal.cpp

index 03bcc4b..20d2b28 100644 (file)
@@ -283,7 +283,9 @@ void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler)
         WifiCommand *cmd = (WifiCommand *)cbi->cb_arg;
         if (cmd != NULL) {
             cmd->addRef();
+            pthread_mutex_unlock(&info->cb_lock);
             cmd->cancel();
+            pthread_mutex_lock(&info->cb_lock);
             cmd->releaseRef();
         }
     }