mempool: fix anonymous populate
The documentation says that a negative errno is returned on error, but in most places that's not the case. Fix the documentation and the exceptions in code. The second one (return from populate_virt) also fixes a memory leak. Note that testpmd was using the function correctly. Fixes:aa10457eb4
("mempool: make mempool populate and free api public") Fixes:6780f72fb8
("mempool: populate with anonymous memory") Fixes:66e7ba0bad
("mempool: ensure mempool is initialized before populating") Cc: stable@dpdk.org Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
This commit is contained in:
parent
725e515ed1
commit
f159c61c35
@ -645,8 +645,10 @@ rte_mempool_populate_anon(struct rte_mempool *mp)
|
||||
}
|
||||
|
||||
ret = mempool_ops_alloc_once(mp);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
if (ret < 0) {
|
||||
rte_errno = -ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
size = get_anon_size(mp);
|
||||
if (size < 0) {
|
||||
@ -670,8 +672,10 @@ rte_mempool_populate_anon(struct rte_mempool *mp)
|
||||
|
||||
ret = rte_mempool_populate_virt(mp, addr, size, getpagesize(),
|
||||
rte_mempool_memchunk_anon_free, addr);
|
||||
if (ret == 0)
|
||||
if (ret < 0) {
|
||||
rte_errno = -ret;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return mp->populated_size;
|
||||
|
||||
|
@ -1167,8 +1167,8 @@ int rte_mempool_populate_default(struct rte_mempool *mp);
|
||||
* A pointer to the mempool structure.
|
||||
* @return
|
||||
* The number of objects added on success.
|
||||
* On error, the chunk is not added in the memory list of the
|
||||
* mempool and a negative errno is returned.
|
||||
* On error, 0 is returned, rte_errno is set, and the chunk is not added in
|
||||
* the memory list of the mempool.
|
||||
*/
|
||||
int rte_mempool_populate_anon(struct rte_mempool *mp);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user