[dpdk-dev,1/2] mempool/dpaa2: fix the return value for alloc fail

Message ID 1495532028-9700-1-git-send-email-hemant.agrawal@nxp.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Hemant Agrawal May 23, 2017, 9:33 a.m. UTC
  In case the alloc api is not able to allocate the required
number of buffer, it can return '0', which will not indicate
the failure to the calling function.
This patch fix the return value to indicate the failure.

Fixes: 5dc43d22b5ad ("mempool/dpaa2: add hardware offloaded mempool")
CC: stable@dpdk.org

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Olivier Matz June 8, 2017, 9:53 a.m. UTC | #1
Hi Hemant,

On Tue, 23 May 2017 15:03:47 +0530, Hemant Agrawal <hemant.agrawal@nxp.com> wrote:
> In case the alloc api is not able to allocate the required
> number of buffer, it can return '0', which will not indicate
> the failure to the calling function.
> This patch fix the return value to indicate the failure.
> 
> Fixes: 5dc43d22b5ad ("mempool/dpaa2: add hardware offloaded mempool")
> CC: stable@dpdk.org
> 
> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
> ---
>  drivers/mempool/dpaa2/dpaa2_hw_mempool.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
> index 5a5d6aa..60dd1c0 100644
> --- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
> +++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
> @@ -294,7 +294,7 @@
>  			/* Releasing all buffers allocated */
>  			rte_dpaa2_mbuf_release(pool, obj_table, bpid,
>  					   bp_info->meta_data_size, n);
> -			return ret;
> +			return -1;
>  		}
>  		/* assigning mbuf from the acquired objects */
>  		for (i = 0; (i < ret) && bufs[i]; i++) {

Wouldn't it be better to return an errno as done in ring handler
(see common_ring_mp_enqueue()) or in stack handler (see stack_alloc())?

Olivier
  

Patch

diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
index 5a5d6aa..60dd1c0 100644
--- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
+++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
@@ -294,7 +294,7 @@ 
 			/* Releasing all buffers allocated */
 			rte_dpaa2_mbuf_release(pool, obj_table, bpid,
 					   bp_info->meta_data_size, n);
-			return ret;
+			return -1;
 		}
 		/* assigning mbuf from the acquired objects */
 		for (i = 0; (i < ret) && bufs[i]; i++) {