From patchwork Thu Aug 2 00:35:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "De Lara Guarch, Pablo" X-Patchwork-Id: 43518 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E3A951B454; Thu, 2 Aug 2018 10:41:30 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 034771B44B for ; Thu, 2 Aug 2018 10:41:29 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Aug 2018 01:41:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,434,1526367600"; d="scan'208";a="61446514" Received: from silpixa00399466.ir.intel.com (HELO silpixa00399466.ger.corp.intel.com) ([10.237.223.220]) by orsmga007.jf.intel.com with ESMTP; 02 Aug 2018 01:41:26 -0700 From: Pablo de Lara To: olivier.matz@6wind.com, arybchenko@solarflare.com Cc: dev@dpdk.org, Pablo de Lara Date: Thu, 2 Aug 2018 01:35:04 +0100 Message-Id: <20180802003504.30679-1-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180717103720.26783-1-pablo.de.lara.guarch@intel.com> References: <20180717103720.26783-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v2] mempool: check for invalid args on creation 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Currently, a mempool can be created if the number of objects is zero. However, in this scenario, rte_mempool_create should return NULL, as the mempool created is useless otherwise. Signed-off-by: Pablo de Lara Acked-by: Andrew Rybchenko --- lib/librte_mempool/rte_mempool.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 8c8b9f809..a24a14887 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -916,6 +916,12 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list); + /* asked for zero items */ + if (n == 0) { + rte_errno = EINVAL; + return NULL; + } + /* asked cache too big */ if (cache_size > RTE_MEMPOOL_CACHE_MAX_SIZE || CALC_CACHE_FLUSHTHRESH(cache_size) > n) {