From patchwork Thu May 25 09:59:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Dabilpuram X-Patchwork-Id: 127417 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3546142B9A; Thu, 25 May 2023 12:11:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EC46042DB7; Thu, 25 May 2023 12:10:18 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 220AF42D84 for ; Thu, 25 May 2023 12:10:14 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34PA2W0N020284 for ; Thu, 25 May 2023 03:10:14 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=3F5qvE8MCgnCTDafuCTzNxAOZNJcI5GGmtdKUPmPiCA=; b=ZbAO3064hl061vgIO9qVppxhiMDSbnBSFJN55mc7UBS+H8elIOalJOkEoZDQAi+5CCQC 3t57xcqDMSVdXEpxcjlmCE9ixOjJWxPl5oS79tXgtkNYcCOsRaq48PCl2YzGzp9bRxpj lKsHdkcMrsLQbavdaxacVlydJ/c3a3qSrTBhsThcrNqpn8UbFglsgTHW8pCr6Kb1LcrW Ul/CxpAgtyhuatcTTB+LUrl8nisWlMAomP3NR2Qt2gmlDmlccqIwcKvt6+RmKEx9PUOO eTjeagFraTFSDK5ql/ihM5wf2GxX29UHF823yUJEt+5Y3ifnzbfT8yEkF/I3Tm5nJp6e 0A== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3qt5jng0pa-13 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 25 May 2023 03:10:14 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 25 May 2023 03:09:49 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 25 May 2023 03:09:48 -0700 Received: from hyd1588t430.caveonetworks.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id B681C5B6E9F; Thu, 25 May 2023 03:00:39 -0700 (PDT) From: Nithin Dabilpuram To: Nithin Kumar Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao CC: , , Gowrishankar Muthukrishnan Subject: [PATCH v3 28/32] common/nix: check for null dereference Date: Thu, 25 May 2023 15:29:00 +0530 Message-ID: <20230525095904.3967080-28-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230525095904.3967080-1-ndabilpuram@marvell.com> References: <20230411091144.1087887-1-ndabilpuram@marvell.com> <20230525095904.3967080-1-ndabilpuram@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 7HFY5mSHjv_uYZYYIq7PLVx93ZLdIXi8 X-Proofpoint-GUID: 7HFY5mSHjv_uYZYYIq7PLVx93ZLdIXi8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-25_06,2023-05-24_01,2023-05-22_02 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Gowrishankar Muthukrishnan Check for NULL value return before dereferencing on it. Signed-off-by: Gowrishankar Muthukrishnan --- drivers/common/cnxk/roc_nix.c | 8 +++++++- drivers/common/cnxk/roc_nix_fc.c | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/common/cnxk/roc_nix.c b/drivers/common/cnxk/roc_nix.c index 39943e4ba7..152ef7269e 100644 --- a/drivers/common/cnxk/roc_nix.c +++ b/drivers/common/cnxk/roc_nix.c @@ -392,6 +392,7 @@ roc_nix_dev_init(struct roc_nix *roc_nix) { enum roc_nix_rss_reta_sz reta_sz; struct plt_pci_device *pci_dev; + struct roc_nix_list *nix_list; uint16_t max_sqb_count; uint64_t blkaddr; struct dev *dev; @@ -417,7 +418,12 @@ roc_nix_dev_init(struct roc_nix *roc_nix) nix = roc_nix_to_nix_priv(roc_nix); pci_dev = roc_nix->pci_dev; dev = &nix->dev; - TAILQ_INSERT_TAIL(roc_idev_nix_list_get(), roc_nix, next); + + nix_list = roc_idev_nix_list_get(); + if (nix_list == NULL) + return -EINVAL; + + TAILQ_INSERT_TAIL(nix_list, roc_nix, next); if (nix->dev.drv_inited) return 0; diff --git a/drivers/common/cnxk/roc_nix_fc.c b/drivers/common/cnxk/roc_nix_fc.c index 44eade5ba6..f79baf9242 100644 --- a/drivers/common/cnxk/roc_nix_fc.c +++ b/drivers/common/cnxk/roc_nix_fc.c @@ -431,13 +431,18 @@ static int nix_rx_chan_multi_bpid_cfg(struct roc_nix *roc_nix, uint8_t chan, uint16_t bpid, uint16_t *bpid_new) { struct roc_nix *roc_nix_tmp, *roc_nix_pre = NULL; + struct roc_nix_list *nix_list; uint8_t chan_pre; if (!roc_feature_nix_has_rxchan_multi_bpid()) return -ENOTSUP; + nix_list = roc_idev_nix_list_get(); + if (nix_list == NULL) + return -EINVAL; + /* Find associated NIX RX channel if Aura BPID is of that of a NIX. */ - TAILQ_FOREACH(roc_nix_tmp, roc_idev_nix_list_get(), next) { + TAILQ_FOREACH(roc_nix_tmp, nix_list, next) { struct nix *nix = roc_nix_to_nix_priv(roc_nix_tmp); int i;