hold regions_lock in alloc_aligned

pull/50/head
Daniel Micay 2018-08-26 04:37:43 -04:00
parent bec20a39cf
commit a13a45a17d
1 changed files with 5 additions and 0 deletions

View File

@ -790,10 +790,15 @@ static int alloc_aligned(void **memptr, size_t alignment, size_t size, size_t mi
if (p == NULL) { if (p == NULL) {
return ENOMEM; return ENOMEM;
} }
pthread_mutex_lock(&regions_lock);
if (regions_insert(p, size)) { if (regions_insert(p, size)) {
pthread_mutex_unlock(&regions_lock);
deallocate_pages(p, size, PAGE_SIZE); deallocate_pages(p, size, PAGE_SIZE);
return ENOMEM; return ENOMEM;
} }
pthread_mutex_unlock(&regions_lock);
*memptr = p; *memptr = p;
return 0; return 0;
} }