From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B94C7A04DC; Mon, 19 Oct 2020 12:50:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 952F8CA60; Mon, 19 Oct 2020 12:50:18 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 95110C9DA for ; Mon, 19 Oct 2020 12:50:15 +0200 (CEST) IronPort-SDR: cQmxyoV4vW8H2epkJPGp9e/+ny/QK1X6+vpJsoqY0os9BntjES4KszuC/xw1Cz3HN10FSbbGa7 CvQJhRGNshIQ== X-IronPort-AV: E=McAfee;i="6000,8403,9778"; a="146300292" X-IronPort-AV: E=Sophos;i="5.77,394,1596524400"; d="scan'208";a="146300292" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2020 03:50:13 -0700 IronPort-SDR: UdKCsKbbIYnsPhBqe3tIak8H8rLuoH+Ne3yVPHeQYMLYCaGBHKcZasPXjEpVia1YXDj15MbIEy qW/hMq+8xvVA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,394,1596524400"; d="scan'208";a="352942200" Received: from silpixa00400629.ir.intel.com ([10.237.214.112]) by fmsmga002.fm.intel.com with ESMTP; 19 Oct 2020 03:50:12 -0700 From: Savinay Dharmappa To: cristian.dumitrescu@intel.com, jasvinder.singh@intel.com, dev@dpdk.org Cc: savinay.dharmappa@intel.com Date: Mon, 19 Oct 2020 11:50:04 +0100 Message-Id: <20201019105004.76433-1-savinay.dharmappa@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH v1] net/softnic: fix out of bound access X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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