From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 4081C5921 for ; Fri, 27 May 2016 13:56:33 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 27 May 2016 04:56:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,373,1459839600"; d="scan'208";a="985874350" Received: from gklab-246-019.igk.intel.com (HELO intel.com) ([10.217.246.19]) by orsmga002.jf.intel.com with SMTP; 27 May 2016 04:56:19 -0700 Received: by intel.com (sSMTP sendmail emulation); Fri, 27 May 2016 14:56:10 +0200 From: Slawomir Mrozowicz To: johndale@cisco.com, neescoba@cisco.com Cc: dev@dpdk.org, Slawomir Mrozowicz Date: Fri, 27 May 2016 14:56:06 +0200 Message-Id: <1464353766-2404-1-git-send-email-slawomirx.mrozowicz@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] enic: negative array index write X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 May 2016 11:56:33 -0000 Negative array index write using variable pos as an index to array enic->fdir.nodes. Fixed by add array index check. Fixes: fefed3d1e62c ("enic: new driver") Coverity ID 13270 Signed-off-by: Slawomir Mrozowicz --- drivers/net/enic/enic_clsf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/enic/enic_clsf.c b/drivers/net/enic/enic_clsf.c index edb56e1..6b1489d 100644 --- a/drivers/net/enic/enic_clsf.c +++ b/drivers/net/enic/enic_clsf.c @@ -213,6 +213,12 @@ int enic_fdir_add_fltr(struct enic *enic, struct rte_eth_fdir_filter *params) } pos = rte_hash_add_key(enic->fdir.hash, params); + if (pos < 0 || pos >= ENICPMD_FDIR_MAX) { + dev_err(enic, "Add hash key failed\n"); + enic->fdir.stats.f_add++; + return -EINVAL; + } + enic->fdir.nodes[pos] = key; return 0; } -- 1.9.1