diff --git a/src/mem/mem_pool.c b/src/mem/mem_pool.c index 3c721debf..404ff6d34 100644 --- a/src/mem/mem_pool.c +++ b/src/mem/mem_pool.c @@ -81,12 +81,12 @@ int mem_pool_alloc(struct mem_pool **poolp, size_t nmemb, size_t membsize, goto error; } + mem_destructor(p, mem_pool_destroy); + err = mutex_alloc(&p->lock); if (err) goto error; - mem_destructor(p, mem_pool_destroy); - for (size_t i = 0; i < nmemb; i++) { p->objs[i].member = mem_zalloc(membsize, dh); if (!p->objs[i].member) {