From: John Daley <johndale@cisco.com>
To: slawomirx.mrozowicz@intel.com, ferruh.yigit@intel.com
Cc: dev@dpdk.org, John Daley <johndale@cisco.com>
Subject: [dpdk-dev] [PATCH v2] enic: negative array index write
Date: Mon, 20 Jun 2016 12:27:46 -0700 [thread overview]
Message-ID: <1466450866-23095-1-git-send-email-johndale@cisco.com> (raw)
In-Reply-To: <5767FF37.1050404@intel.com>
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: John Daley <johndale@cisco.com>
---
Here is a version 2. Differences with fix proposed by Slawomir Mrozowicz:
- handle the return code error condition for both calls to rte_hash_add_key()
not just the the 2nd one.
- no need to check for pos >= ENICPMD_FDIR_MAX since it should already be
validated by rte_hash_add_key(). rte_hash_create() takes an 'entries'
parameter which is used to cap the max return value of rte_hash_add_key().
- when pos is < 0, return the actual error (pos), instead of -EINVAL.
drivers/net/enic/enic_clsf.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/net/enic/enic_clsf.c b/drivers/net/enic/enic_clsf.c
index edb56e1..7d2bb78 100644
--- a/drivers/net/enic/enic_clsf.c
+++ b/drivers/net/enic/enic_clsf.c
@@ -148,9 +148,13 @@ int enic_fdir_add_fltr(struct enic *enic, struct rte_eth_fdir_filter *params)
enic->fdir.nodes[pos] = NULL;
if (unlikely(key->rq_index == queue)) {
/* Nothing to be done */
+ enic->fdir.stats.f_add++;
pos = rte_hash_add_key(enic->fdir.hash, params);
+ if (pos < 0) {
+ dev_err(enic, "Add hash key failed\n");
+ return pos;
+ }
enic->fdir.nodes[pos] = key;
- enic->fdir.stats.f_add++;
dev_warning(enic,
"FDIR rule is already present\n");
return 0;
@@ -213,6 +217,11 @@ 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) {
+ dev_err(enic, "Add hash key failed\n");
+ return pos;
+ }
+
enic->fdir.nodes[pos] = key;
return 0;
}
--
2.7.0
next prev parent reply other threads:[~2016-06-20 19:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-27 12:56 [dpdk-dev] [PATCH] " Slawomir Mrozowicz
2016-06-20 14:35 ` Ferruh Yigit
2016-06-20 19:27 ` John Daley [this message]
2016-06-24 11:44 ` [dpdk-dev] [PATCH v2] " 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=1466450866-23095-1-git-send-email-johndale@cisco.com \
--to=johndale@cisco.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=slawomirx.mrozowicz@intel.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).