From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id E02932B94; Sat, 27 Oct 2018 02:43:25 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Oct 2018 17:43:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,429,1534834800"; d="scan'208";a="244738085" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by orsmga004.jf.intel.com with ESMTP; 26 Oct 2018 17:43:22 -0700 From: Fiona Trahe To: dev@dpdk.org Cc: thomas@monjalon.net, akhil.goyal@nxp.com, tomaszx.jozwiak@intel.com, sabyasg@hpe.com, shally.verma@caviumnetworks.com, Fiona Trahe , stable@dpdk.org Date: Sat, 27 Oct 2018 01:43:07 +0100 Message-Id: <1540600987-8101-1-git-send-email-fiona.trahe@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1540599469-21696-1-git-send-email-fiona.trahe@intel.com> References: <1540599469-21696-1-git-send-email-fiona.trahe@intel.com> Subject: [dpdk-dev] [PATCH v2] lib/compressdev: Fix logic error on op allocation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Oct 2018 00:43:26 -0000 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@dpdk.org Reported-by: Sabyasachi Sengupta Signed-off-by: Fiona Trahe --- 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