From: Savinay Dharmappa <savinay.dharmappa@intel.com>
To: cristian.dumitrescu@intel.com, jasvinder.singh@intel.com, dev@dpdk.org
Cc: savinay.dharmappa@intel.com
Subject: [dpdk-dev] [PATCH v1] net/softnic: fix out of bound access
Date: Mon, 19 Oct 2020 11:50:04 +0100 [thread overview]
Message-ID: <20201019105004.76433-1-savinay.dharmappa@intel.com> (raw)
This patch fixes out of bound access of an array.
Coverity issue: 363466, 363459
Fixes: b5dfa6703d49 ("net/softnic: update subport rate dynamically")
Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
---
drivers/net/softnic/rte_eth_softnic_tm.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/softnic/rte_eth_softnic_tm.c b/drivers/net/softnic/rte_eth_softnic_tm.c
index 725b0231ae..df09d62d70 100644
--- a/drivers/net/softnic/rte_eth_softnic_tm.c
+++ b/drivers/net/softnic/rte_eth_softnic_tm.c
@@ -1147,10 +1147,15 @@ update_subport_tc_rate(struct rte_eth_dev *dev,
struct tm_node *ns = np->parent_node;
uint32_t subport_id = tm_node_subport_id(dev, ns);
struct tm_params *t = &p->soft.tm.params;
- uint32_t subport_profile_id = t->subport_to_profile[subport_id];
+ uint32_t subport_profile_id;
struct tm_shaper_profile *sp_old = tm_shaper_profile_search(dev,
ss->shaper_profile_id);
+ if (subport_id < TM_MAX_SUBPORT_PROFILE)
+ subport_profile_id = t->subport_to_profile[subport_id];
+ else
+ return -1;
+
/* Derive new subport configuration. */
memcpy(&subport_profile,
&p->soft.tm.params.subport_profile[subport_profile_id],
@@ -2370,7 +2375,10 @@ subport_profile_get(struct rte_eth_dev *dev, struct tm_node *np)
struct tm_params *t = &p->soft.tm.params;
uint32_t subport_id = tm_node_subport_id(dev, np->parent_node);
- return &t->subport_profile[subport_id];
+ if (subport_id < TM_MAX_SUBPORT_PROFILE)
+ return &t->subport_profile[subport_id];
+ else
+ return NULL;
}
static void
@@ -3024,6 +3032,9 @@ update_subport_rate(struct rte_eth_dev *dev,
struct rte_sched_subport_profile_params profile1;
uint32_t subport_profile_id;
+ if (profile0 == NULL)
+ return -1;
+
/* Derive new pipe profile. */
memcpy(&profile1, profile0, sizeof(profile1));
profile1.tb_rate = sp->params.peak.rate;
--
2.17.1
next reply other threads:[~2020-10-19 10:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-19 10:50 Savinay Dharmappa [this message]
2020-10-19 10:55 ` Dumitrescu, Cristian
2020-10-19 11:52 ` [dpdk-dev] [PATCH v2] " Savinay Dharmappa
2020-10-19 13:16 ` Dumitrescu, Cristian
2020-10-20 15:48 ` Ferruh Yigit
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=20201019105004.76433-1-savinay.dharmappa@intel.com \
--to=savinay.dharmappa@intel.com \
--cc=cristian.dumitrescu@intel.com \
--cc=dev@dpdk.org \
--cc=jasvinder.singh@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).