From patchwork Tue Apr 11 09:11:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Dabilpuram X-Patchwork-Id: 125916 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 C39B14291B; Tue, 11 Apr 2023 11:13:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 57C3442D3C; Tue, 11 Apr 2023 11:12:37 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 905A242D3C for ; Tue, 11 Apr 2023 11:12:35 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33B8g4Di014876 for ; Tue, 11 Apr 2023 02:12:35 -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=8H3vkhwEdfG0Xnaz+pnpBe5Xnla9mGuIsHKFC6KYMu8=; b=ct3AZu3o6Wfc6nviPCNFOnEPJ2Z2c3A/yOkUoTpJtkRoECO44n4N9HKxZCr0Oor2CTyT 7s1Lw2v3WO3hgqHaK7RRU5C47x/IHEMvMdECxlw3kyzgaK0qbiVFw0RAc2FyJnujWP7+ ta7e/nijSlRtwkpR/tsLaoWTO2Tfe+f5yNME1l5uB9JOJ+CVaNjavz6nmiJ5OMnozbhT YBK38UUi2/tmRFXRx+7b2cgLd7oGgL+6SbpP1JfhZI8XtZ3nYS4B/Cwtf4M/g9bM8Y5g QqtCo3fPU4s+qo0fuD6+mFOOWLtS7Z2W5gopzkS1SP06Jhok+E10zRg1PFAdJB8JF3YO rw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3purfs94h5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 11 Apr 2023 02:12:34 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 11 Apr 2023 02:12:32 -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; Tue, 11 Apr 2023 02:12:32 -0700 Received: from hyd1588t430.caveonetworks.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 6A0353F7071; Tue, 11 Apr 2023 02:12:30 -0700 (PDT) From: Nithin Dabilpuram To: Nithin Kumar Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao CC: , , Gowrishankar Muthukrishnan Subject: [PATCH 11/21] common/cnxk: fix null pointer dereference Date: Tue, 11 Apr 2023 14:41:34 +0530 Message-ID: <20230411091144.1087887-11-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411091144.1087887-1-ndabilpuram@marvell.com> References: <20230411091144.1087887-1-ndabilpuram@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: WQusO-8XG37X0t6fYcRs4mv6F-xQCqSo X-Proofpoint-GUID: WQusO-8XG37X0t6fYcRs4mv6F-xQCqSo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-11_05,2023-04-06_03,2023-02-09_01 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 Fix null pointer dereferences reported by klocwork. Fixes: 4398c4092f3d ("common/cnxk: dump inline device RQ context") Fixes: 79dc6f324e82 ("common/cnxk: add inline function for statistics") Signed-off-by: Gowrishankar Muthukrishnan --- drivers/common/cnxk/roc_nix_debug.c | 8 +++++++- drivers/common/cnxk/roc_nix_inl_dev.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/common/cnxk/roc_nix_debug.c b/drivers/common/cnxk/roc_nix_debug.c index 399d0d7eae..a1c3db284b 100644 --- a/drivers/common/cnxk/roc_nix_debug.c +++ b/drivers/common/cnxk/roc_nix_debug.c @@ -733,7 +733,13 @@ roc_nix_queues_ctx_dump(struct roc_nix *roc_nix, FILE *file) inl_rq = roc_nix_inl_dev_rq(roc_nix); if (inl_rq) { struct idev_cfg *idev = idev_get_cfg(); - struct nix_inl_dev *inl_dev = idev->nix_inl_dev; + struct nix_inl_dev *inl_dev = NULL; + + if (idev && idev->nix_inl_dev) + inl_dev = idev->nix_inl_dev; + + if (!inl_dev) + return -EINVAL; rc = nix_q_ctx_get(&inl_dev->dev, NIX_AQ_CTYPE_RQ, inl_rq->qid, &ctx); if (rc) { diff --git a/drivers/common/cnxk/roc_nix_inl_dev.c b/drivers/common/cnxk/roc_nix_inl_dev.c index 196a04db09..b6abafd5c4 100644 --- a/drivers/common/cnxk/roc_nix_inl_dev.c +++ b/drivers/common/cnxk/roc_nix_inl_dev.c @@ -843,7 +843,7 @@ roc_nix_inl_dev_stats_get(struct roc_nix_stats *stats) if (stats == NULL) return NIX_ERR_PARAM; - if (!idev && idev->nix_inl_dev) + if (idev && idev->nix_inl_dev) inl_dev = idev->nix_inl_dev; if (!inl_dev)