diff options
author | Gurpreet Ghai <gghai@codeaurora.org> | 2016-02-18 11:13:10 +0530 |
---|---|---|
committer | Gurpreet Ghai <gghai@codeaurora.org> | 2016-02-18 15:01:02 +0530 |
commit | e27390257a37b691b99ab96ab61326ca1f6a9239 (patch) | |
tree | f337a9785078fc8cefed87c6fa6ac95c7b321bde | |
parent | af69c1e623a79119e9b8180d23671a661bdb1eab (diff) | |
download | android_system_bt-e27390257a37b691b99ab96ab61326ca1f6a9239.tar.gz android_system_bt-e27390257a37b691b99ab96ab61326ca1f6a9239.tar.bz2 android_system_bt-e27390257a37b691b99ab96ab61326ca1f6a9239.zip |
Bluetooth: Synchronizing access to hashmap in counter module
The hashmap access is not synchronized in counter module.
The call for hashmap free is not under motex lock. This
may lead to race condition during shut down when hash map
is being cleared while in use by another thread.
Added mutex lock for hash map free call.
CRs-Fixed: 978566
Change-Id: I58dae83a1e483c50f63176df401c02c63e648b8a
-rw-r--r-- | btcore/src/counter.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/btcore/src/counter.c b/btcore/src/counter.c index b88c7a27e..92248b237 100644 --- a/btcore/src/counter.c +++ b/btcore/src/counter.c @@ -136,7 +136,9 @@ static future_t *counter_init(void) { static future_t *counter_clean_up(void) { counter_socket_close(); + pthread_mutex_lock(&hash_map_lock_); hash_map_free(hash_map_counter_); + pthread_mutex_unlock(&hash_map_lock_); pthread_mutex_destroy(&hash_map_lock_); hash_map_counter_ = NULL; return future_new_immediate(FUTURE_SUCCESS); |