From patchwork Fri Feb 25 04:59:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Satha Koteswara Rao Kottidi X-Patchwork-Id: 108341 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 6F3F5A034C; Fri, 25 Feb 2022 06:00:01 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AFF0C4115C; Fri, 25 Feb 2022 05:59:53 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 44A5241169 for ; Fri, 25 Feb 2022 05:59:50 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 21ONcaQ4001083 for ; Thu, 24 Feb 2022 20:59:49 -0800 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-type; s=pfpt0220; bh=1OVS+Iw8f3KtM+GTtQiYC31qoC9q6L1z+DV+dlvunds=; b=TsPSnzmowYiLb+IZ6sZzsR52kpkM4G3PTjdjgj+dE+bw/j/hoRooV9j59WhkcLwUHHhH Ma6JmhU9ZAjdQQyxfp66SNHOFO5rEgbuhXFF/6ARwTjiVBlvd93tiiWa7NBXvDEt45m7 XYR9jbzlzO+Wqq2sMi0vDMjqhaw9/ef9KbCa8SAF8f9IQB4ZQS6F8WHPFaB/ZQgUQZ1+ djhpyH774DAYkOKlkgmw8VuC5nGQeotupUxcx4WER4ohkK7aMcKhZ79Q86T8ekmkAPSn CCU1QLrVIzFLiV5ecbTS8cQP83F988eFE7yXm9qnBhJ8Y85xAQsTq/zVSUwkuLWJOiAt rg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3eegm821uj-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 24 Feb 2022 20:59:49 -0800 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.2; Thu, 24 Feb 2022 20:59:43 -0800 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.18 via Frontend Transport; Thu, 24 Feb 2022 20:59:43 -0800 Received: from cavium.localdomain (unknown [10.28.34.26]) by maili.marvell.com (Postfix) with ESMTP id 3B71A3F70A1; Thu, 24 Feb 2022 20:59:41 -0800 (PST) From: To: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao CC: Subject: [PATCH v2 3/3] common/cnxk: check SQ node before setting bp config Date: Thu, 24 Feb 2022 23:59:26 -0500 Message-ID: <1645765166-19038-3-git-send-email-skoteshwar@marvell.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1645765166-19038-1-git-send-email-skoteshwar@marvell.com> References: <1645696672-5518-1-git-send-email-skoteshwar@marvell.com> <1645765166-19038-1-git-send-email-skoteshwar@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: WOElgz2uNAV8p-FWZnUUaksInn2nhR7j X-Proofpoint-GUID: WOElgz2uNAV8p-FWZnUUaksInn2nhR7j X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-02-25_01,2022-02-24_01,2022-02-23_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: Satha Rao Validate sq_node and parent before accessing their fields. SQ was created without any associated TM node, this is valid negative case, so return success while stopping TM without SQ node. Signed-off-by: Satha Rao --- drivers/common/cnxk/roc_nix_tm.c | 8 ++++++-- drivers/common/cnxk/roc_nix_tm_ops.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/common/cnxk/roc_nix_tm.c b/drivers/common/cnxk/roc_nix_tm.c index 5b23ecd..7a17780 100644 --- a/drivers/common/cnxk/roc_nix_tm.c +++ b/drivers/common/cnxk/roc_nix_tm.c @@ -325,14 +325,17 @@ struct mbox *mbox = (&nix->dev)->mbox; struct nix_txschq_config *req = NULL; struct nix_tm_node_list *list; + uint16_t link = nix->tx_link; struct nix_tm_node *sq_node; struct nix_tm_node *parent; struct nix_tm_node *node; uint8_t k = 0; - uint16_t link; int rc = 0; sq_node = nix_tm_node_search(nix, sq, nix->tm_tree); + if (!sq_node) + return -ENOENT; + parent = sq_node->parent; while (parent) { if (parent->lvl == ROC_TM_LVL_SCH2) @@ -340,9 +343,10 @@ parent = parent->parent; } + if (!parent) + return -ENOENT; list = nix_tm_node_list(nix, tree); - link = nix->tx_link; if (parent->rel_chan != NIX_TM_CHAN_INVALID && parent->rel_chan != tc) { rc = -EINVAL; diff --git a/drivers/common/cnxk/roc_nix_tm_ops.c b/drivers/common/cnxk/roc_nix_tm_ops.c index 5a25b3e..1d9a02b 100644 --- a/drivers/common/cnxk/roc_nix_tm_ops.c +++ b/drivers/common/cnxk/roc_nix_tm_ops.c @@ -474,7 +474,7 @@ continue; rc = nix_tm_bp_config_set(roc_nix, sq->qid, 0, false); - if (rc) { + if (rc && rc != -ENOENT) { plt_err("Failed to disable backpressure, rc=%d", rc); goto cleanup; }