From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7A6B74565E; Tue, 30 Jul 2024 09:08:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 11C1740041; Tue, 30 Jul 2024 09:08:56 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by mails.dpdk.org (Postfix) with ESMTP id 9F0C240E22 for ; Fri, 26 Jul 2024 16:55:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1722005709; x=1753541709; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=zp8XEMWd6DOTX0zpdi1VLbcBu34dZytZi9g1xw4vYDE=; b=EDkS6mjDA+GUs3sdDv2crac1xY6v6V+S3RM/ZPqCQ+/j2LqdJufxQdpR ytRD8d206d8vNQvcwTCEEVGN2blJup00PDJKopaPYV6B0t6GhysPo/wIF KZ4r36502qhwwM74vCzo2+oIrrpjXJW5KidILMjaAgdWucwibRtMDKbLb 7o2Hkz+eOjmorLcrZ2DtkCBntFJa1xWEdmxi/qyxOKSp3JmHwtL4ZWaPe KYqYxgnBW1E0NgjnqfaP37w+lBU/g5CiKTNFgEUmJkIV/m54lsk777QJK khpJM80Fw6vqC3TSeRr4+e24KhZIgnaWRlpwX6qp9+vqCgUvRCttS4uUQ Q==; X-CSE-ConnectionGUID: bbtdDBWDRsiEX/91Twyt9A== X-CSE-MsgGUID: pnpf357IQ6Ot8Kjx+VWX9A== X-IronPort-AV: E=McAfee;i="6700,10204,11145"; a="19677856" X-IronPort-AV: E=Sophos;i="6.09,238,1716274800"; d="scan'208";a="19677856" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2024 07:55:07 -0700 X-CSE-ConnectionGUID: yfAwK52GRiWwWe6QXcLASw== X-CSE-MsgGUID: gYaWZCKpRFymkeslFiYJww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,238,1716274800"; d="scan'208";a="58115607" Received: from silpixa00401214-oob.ir.intel.com (HELO silpixa00401183.ir.intel.com) ([10.55.128.107]) by orviesa003.jf.intel.com with ESMTP; 26 Jul 2024 07:55:05 -0700 From: Niall Meade To: Thomas Monjalon , Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin Cc: dev@dpdk.org, Niall Meade Subject: [PATCH] hash: separate param checks in hash create func Date: Fri, 26 Jul 2024 14:54:43 +0000 Message-Id: <20240726145443.1058676-1-niall.meade@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Organization: Intel Research and Development Ireland Ltd - Co. Reg. #308263 - Collinstown Industrial Park, Leixlip, County Kildare, Ireland Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Tue, 30 Jul 2024 09:02:22 +0200 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Separated name, entries and key_len parameter checks in rte_hash_create(). Also made the error messages more informative/verbose to help with debugging. Also added myself to the mailing list. Signed-off-by: Niall Meade --- I had name set to NULL in the parameters I was passing to rte_hash_create() and the error message I got didn't specify which parameter was invalid. --- .mailmap | 1 + lib/hash/rte_cuckoo_hash.c | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.mailmap b/.mailmap index 8aef1c59a4..e2a1d55203 100644 --- a/.mailmap +++ b/.mailmap @@ -1054,6 +1054,7 @@ Nelson Escobar Nemanja Marjanovic Netanel Belgazal Netanel Gonen +Niall Meade Niall Power Nicholas Pratte Nick Connolly diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 577b5839d3..97d55ca23b 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -190,11 +190,18 @@ rte_hash_create(const struct rte_hash_parameters *params) /* Check for valid parameters */ if ((params->entries > RTE_HASH_ENTRIES_MAX) || - (params->entries < RTE_HASH_BUCKET_ENTRIES) || - (params->name == NULL) || - (params->key_len == 0)) { + (params->entries < RTE_HASH_BUCKET_ENTRIES)) { rte_errno = EINVAL; - HASH_LOG(ERR, "%s has invalid parameters", __func__); + HASH_LOG(ERR, "%s has invalid parameters, entries must be " + "in the range %d to %d inclusive", __func__, + RTE_HASH_BUCKET_ENTRIES, RTE_HASH_ENTRIES_MAX); + return NULL; + } + + if (params->key_len == 0) { + rte_errno = EINVAL; + HASH_LOG(ERR, "%s has invalid parameters, key_len must be " + "greater than 0", __func__); return NULL; } @@ -204,6 +211,13 @@ rte_hash_create(const struct rte_hash_parameters *params) return NULL; } + if (params->name == NULL) { + rte_errno = EINVAL; + HASH_LOG(ERR, "%s has invalid parameters, name can't be NULL", + __func__); + return NULL; + } + /* Validate correct usage of extra options */ if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) && (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) { -- 2.34.1 -------------------------------------------------------------- Intel Research and Development Ireland Limited Registered in Ireland Registered Office: Collinstown Industrial Park, Leixlip, County Kildare Registered Number: 308263 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.