From: Satha Rao <skotesh...@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 <skotesh...@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(-)

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

Reply via email to