[v2,3/3] common/cnxk: check SQ node before setting bp config

Message ID 1645765166-19038-3-git-send-email-skoteshwar@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series [v2,1/3] common/cnxk: enable packet marking |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation warning apply issues

Commit Message

Satha Koteswara Rao Kottidi Feb. 25, 2022, 4:59 a.m. UTC
  From: Satha Rao <skoteshwar@marvell.com>

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 <skoteshwar@marvell.com>
---
 drivers/common/cnxk/roc_nix_tm.c     | 8 ++++++--
 drivers/common/cnxk/roc_nix_tm_ops.c | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)
  

Patch

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;
 		}