patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] mempool: fix anonymous populate
@ 2020-01-17 14:34 Olivier Matz
  2020-01-20 10:08 ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Olivier Matz @ 2020-01-17 14:34 UTC (permalink / raw)
  To: dev; +Cc: Andrew Rybchenko, stable

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: aa10457eb4c2 ("mempool: make mempool populate and free api public")
Fixes: 6780f72fb82f ("mempool: populate with anonymous memory")
Fixes: 66e7ba0bad4c ("mempool: ensure mempool is initialized before populating")
Cc: stable@dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 lib/librte_mempool/rte_mempool.c | 10 +++++++---
 lib/librte_mempool/rte_mempool.h |  4 ++--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 78d8eb941..f8d453d21 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -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;
 
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index f81152af9..0a1dc6059 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -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);
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH] mempool: fix anonymous populate
  2020-01-17 14:34 [dpdk-stable] [PATCH] mempool: fix anonymous populate Olivier Matz
@ 2020-01-20 10:08 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2020-01-20 10:08 UTC (permalink / raw)
  To: Olivier Matz; +Cc: dev, Andrew Rybchenko, stable

17/01/2020 15:34, Olivier Matz:
> 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: aa10457eb4c2 ("mempool: make mempool populate and free api public")
> Fixes: 6780f72fb82f ("mempool: populate with anonymous memory")
> Fixes: 66e7ba0bad4c ("mempool: ensure mempool is initialized before populating")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>

Applied, thanks




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-20 10:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-17 14:34 [dpdk-stable] [PATCH] mempool: fix anonymous populate Olivier Matz
2020-01-20 10:08 ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git