fbarray: fix init unlock without lock

Certain failure paths of rte_fbarray_init() will unlock the
mem area lock without locking it first. Fix this by properly
handling the failures.

Fixes: 5b61c62cfd76 ("fbarray: add internal tailq for mapped areas")

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
This commit is contained in:
Anatoly Burakov 2019-03-29 10:57:08 +00:00 committed by Thomas Monjalon
parent 5a98bc5e83
commit b8a86c83e0

View File

@ -736,15 +736,19 @@ rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len,
}
page_sz = sysconf(_SC_PAGESIZE);
if (page_sz == (size_t)-1)
goto fail;
if (page_sz == (size_t)-1) {
free(ma);
return -1;
}
/* calculate our memory limits */
mmap_len = calc_data_size(page_sz, elt_sz, len);
data = eal_get_virtual_area(NULL, &mmap_len, page_sz, 0, 0);
if (data == NULL)
goto fail;
if (data == NULL) {
free(ma);
return -1;
}
rte_spinlock_lock(&mem_area_lock);