From d120c08958d8a05e9c5791c6e49c99d79eb664a0 Mon Sep 17 00:00:00 2001 From: Satha Rao Date: Thu, 24 Feb 2022 23:59:26 -0500 Subject: [PATCH] common/cnxk: check SQ node before setting BP config 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 Acked-by: Jerin Jacob --- 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 5b23ecd414..7a17780058 100644 --- a/drivers/common/cnxk/roc_nix_tm.c +++ b/drivers/common/cnxk/roc_nix_tm.c @@ -325,14 +325,17 @@ nix_tm_bp_config_set(struct roc_nix *roc_nix, uint16_t sq, uint16_t tc, 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 @@ nix_tm_bp_config_set(struct roc_nix *roc_nix, uint16_t sq, uint16_t tc, 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 5a25b3e9b0..1d9a02bc06 100644 --- a/drivers/common/cnxk/roc_nix_tm_ops.c +++ b/drivers/common/cnxk/roc_nix_tm_ops.c @@ -474,7 +474,7 @@ roc_nix_tm_hierarchy_disable(struct roc_nix *roc_nix) 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; } -- 2.20.1