summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2015-12-04 02:38:20 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2015-12-04 02:38:20 -0800
commit68bd41eadfe9db31f8f251bbeecc61af75557a86 (patch)
treee0923c6c3afdd90ad74cd6893e2b4171874b1b6e
parent74a2952e414d75028bf1078ddd314dbe4cc9c0c8 (diff)
parentcc6166eb6f569455a9746bd20286f296d894903d (diff)
downloadandroid_system_bt-68bd41eadfe9db31f8f251bbeecc61af75557a86.tar.gz
android_system_bt-68bd41eadfe9db31f8f251bbeecc61af75557a86.tar.bz2
android_system_bt-68bd41eadfe9db31f8f251bbeecc61af75557a86.zip
Merge "Bluetooth: Free hash map entry to avoid memory leak" into LA.BF.1.1.3_rb1.5
-rw-r--r--osi/include/allocation_tracker.h2
-rw-r--r--osi/src/allocation_tracker.c7
2 files changed, 9 insertions, 0 deletions
diff --git a/osi/include/allocation_tracker.h b/osi/include/allocation_tracker.h
index b9fa59405..d4934dbe0 100644
--- a/osi/include/allocation_tracker.h
+++ b/osi/include/allocation_tracker.h
@@ -22,6 +22,8 @@
#include <stddef.h>
#include <stdint.h>
+#define OSI_ALLOC_TRACK_DOUBLE_FREE FALSE
+
typedef struct allocation_tracker_t allocation_tracker_t;
typedef uint8_t allocator_id_t;
diff --git a/osi/src/allocation_tracker.c b/osi/src/allocation_tracker.c
index 0124b68c3..2ef3983aa 100644
--- a/osi/src/allocation_tracker.c
+++ b/osi/src/allocation_tracker.c
@@ -170,6 +170,13 @@ void *allocation_tracker_notify_free(uint8_t allocator_id, void *ptr) {
assert(end_canary[i] == canary[i]);
}
+ // free hash map entry to avoid memory leak on long run.
+ // double free detected with above assert(allocation)
+ // as the allocation entry will not present.
+#if (defined(OSI_ALLOC_TRACK_DOUBLE_FREE) && (OSI_ALLOC_TRACK_DOUBLE_FREE == FALSE))
+ hash_map_erase(allocations, ptr);
+#endif
+
pthread_mutex_unlock(&lock);
return ((char *)ptr) - canary_size;