[dpdk-dev] [PATCH v2] lib/compressdev: Fix logic error on op allocation

Verma, Shally Shally.Verma at cavium.com
Tue Oct 30 15:00:13 CET 2018



>-----Original Message-----
>From: Fiona Trahe <fiona.trahe at intel.com>
>Sent: 27 October 2018 06:13
>To: dev at dpdk.org
>Cc: thomas at monjalon.net; akhil.goyal at nxp.com; tomaszx.jozwiak at intel.com; sabyasg at hpe.com; Verma, Shally
><Shally.Verma at cavium.com>; Fiona Trahe <fiona.trahe at intel.com>; stable at dpdk.org
>Subject: [PATCH v2] lib/compressdev: Fix logic error on op allocation
>
>External Email
>
>Fixed bad logic in rte_comp_op_alloc() checking return
>value from rte_comp_op_raw_bulk_alloc(). This
>could have resulted in a seg-fault in error case.
>Made rte_comp_ob_bulk_alloc() code consistent
>with rte_comp_op_alloc().
>
>
>Fixes: 96086db5a369 ("compressdev: add operation management")
>Cc: stable at dpdk.org
>
>Reported-by: Sabyasachi Sengupta <sabyasg at hpe.com>
>Signed-off-by: Fiona Trahe <fiona.trahe at intel.com>
>---
>v2 change:
> - added Reported-by tag
>
> lib/librte_compressdev/rte_comp.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
>diff --git a/lib/librte_compressdev/rte_comp.c b/lib/librte_compressdev/rte_comp.c
>index c663be5..4634c12 100644
>--- a/lib/librte_compressdev/rte_comp.c
>+++ b/lib/librte_compressdev/rte_comp.c
>@@ -174,7 +174,7 @@ rte_comp_op_alloc(struct rte_mempool *mempool)
>        int retval;
>
>        retval = rte_comp_op_raw_bulk_alloc(mempool, &op, 1);
>-       if (unlikely(retval < 0))
>+       if (unlikely(retval != 1))
>                return NULL;
>
>        rte_comp_op_reset(op);
>@@ -186,12 +186,12 @@ int __rte_experimental
> rte_comp_op_bulk_alloc(struct rte_mempool *mempool,
>                struct rte_comp_op **ops, uint16_t nb_ops)
> {
>-       int ret;
>+       int retval;
>        uint16_t i;
>
>-       ret = rte_comp_op_raw_bulk_alloc(mempool, ops, nb_ops);
>-       if (unlikely(ret < nb_ops))
>-               return ret;
>+       retval = rte_comp_op_raw_bulk_alloc(mempool, ops, nb_ops);
>+       if (unlikely(retval != nb_ops))
>+               return 0;
>
>        for (i = 0; i < nb_ops; i++)
>                rte_comp_op_reset(ops[i]);
>--
>2.7.4
Acked-by: Shally Verma <Shally.Verma at caviumnetworks.com>



More information about the dev mailing list