DPDK patches and discussions
 help / color / mirror / Atom feed
From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
To: johndale@cisco.com, neescoba@cisco.com
Cc: dev@dpdk.org, Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Subject: [dpdk-dev] [PATCH] enic: negative array index write
Date: Fri, 27 May 2016 14:56:06 +0200	[thread overview]
Message-ID: <1464353766-2404-1-git-send-email-slawomirx.mrozowicz@intel.com> (raw)

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 <slawomirx.mrozowicz@intel.com>
---
 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

             reply	other threads:[~2016-05-27 11:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-27 12:56 Slawomir Mrozowicz [this message]
2016-06-20 14:35 ` Ferruh Yigit
2016-06-20 19:27   ` [dpdk-dev] [PATCH v2] " John Daley
2016-06-24 11:44     ` Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1464353766-2404-1-git-send-email-slawomirx.mrozowicz@intel.com \
    --to=slawomirx.mrozowicz@intel.com \
    --cc=dev@dpdk.org \
    --cc=johndale@cisco.com \
    --cc=neescoba@cisco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).