[v2,1/2] mempool: fix rte_errno in rte_mempool_create_empty

Message ID 20250120122156.2480524-2-ariel.otilibili@6wind.com (mailing list archive)
State Accepted
Delegated to: Thomas Monjalon
Headers
Series add rte_errno to rte_mempool_create_empty, and refactor |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ariel Otilibili Jan. 20, 2025, 12:21 p.m. UTC
When returning from rte_mempool_set_ops_byname(), rte_errno is not set
for error exits.

The API requires rte_errno to be set in that case.

Bugzilla ID: 1559
Fixes: c2c6b2f41305 ("mempool: fix default ops for an empty mempool")
Link: https://doc.dpdk.org/api/rte__mempool_8h.html#a82e301ee33ed7a263ceb4582655dc3ea
Signed-off-by: Ariel Otilibili <ariel.otilibili@6wind.com>
---
 lib/mempool/rte_mempool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

fengchengwen Jan. 24, 2025, 6:47 a.m. UTC | #1
Acked-by: Chengwen Feng <fengchengwen@huawei.com>

On 2025/1/20 20:21, Ariel Otilibili wrote:
> When returning from rte_mempool_set_ops_byname(), rte_errno is not set
> for error exits.
> 
> The API requires rte_errno to be set in that case.
> 
> Bugzilla ID: 1559
> Fixes: c2c6b2f41305 ("mempool: fix default ops for an empty mempool")
> Link: https://doc.dpdk.org/api/rte__mempool_8h.html#a82e301ee33ed7a263ceb4582655dc3ea
> Signed-off-by: Ariel Otilibili <ariel.otilibili@6wind.com>
  
Konstantin Ananyev Feb. 7, 2025, 2:30 p.m. UTC | #2
> 
> When returning from rte_mempool_set_ops_byname(), rte_errno is not set
> for error exits.
> 
> The API requires rte_errno to be set in that case.
> 
> Bugzilla ID: 1559
> Fixes: c2c6b2f41305 ("mempool: fix default ops for an empty mempool")
> Link: https://doc.dpdk.org/api/rte__mempool_8h.html#a82e301ee33ed7a263ceb4582655dc3ea
> Signed-off-by: Ariel Otilibili <ariel.otilibili@6wind.com>
> ---
>  lib/mempool/rte_mempool.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
> index d8e39e5c2072..1e4f24783c0b 100644
> --- a/lib/mempool/rte_mempool.c
> +++ b/lib/mempool/rte_mempool.c
> @@ -928,8 +928,10 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
>  	else
>  		ret = rte_mempool_set_ops_byname(mp, "ring_mp_mc", NULL);
> 
> -	if (ret)
> +	if (ret) {
> +		rte_errno = -ret;
>  		goto exit_unlock;
> +	}
> 
>  	/*
>  	 * local_cache pointer is set even if cache_size is zero.
> --

Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> 

> 2.30.2
  
Thomas Monjalon Feb. 12, 2025, 2:13 p.m. UTC | #3
07/02/2025 15:30, Konstantin Ananyev:
> 
> > 
> > When returning from rte_mempool_set_ops_byname(), rte_errno is not set
> > for error exits.
> > 
> > The API requires rte_errno to be set in that case.
> > 
> > Bugzilla ID: 1559
> > Fixes: c2c6b2f41305 ("mempool: fix default ops for an empty mempool")
> > Link: https://doc.dpdk.org/api/rte__mempool_8h.html#a82e301ee33ed7a263ceb4582655dc3ea
> > Signed-off-by: Ariel Otilibili <ariel.otilibili@6wind.com>
> 
> Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> 
Acked-by: Chengwen Feng <fengchengwen@huawei.com>

Adding missing Cc: stable@dpdk.org

This patch is applied alone, leaving the second one for consideration or drop.
  

Patch

diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index d8e39e5c2072..1e4f24783c0b 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -928,8 +928,10 @@  rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 	else
 		ret = rte_mempool_set_ops_byname(mp, "ring_mp_mc", NULL);
 
-	if (ret)
+	if (ret) {
+		rte_errno = -ret;
 		goto exit_unlock;
+	}
 
 	/*
 	 * local_cache pointer is set even if cache_size is zero.