common/cnxk: fix uninitialized pointer read
authorGowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Sat, 12 Feb 2022 12:38:20 +0000 (18:08 +0530)
committerJerin Jacob <jerinj@marvell.com>
Fri, 18 Feb 2022 04:20:47 +0000 (05:20 +0100)
Fix uninitialized pointer read reported in coverity scan.

Coverity issue: 370214, 370217, 370219, 370220, 370221
Coverity issue: 370223, 370224, 370225, 372065
Fixes: c34ea71b878d ("common/cnxk: add NPC parsing API")
Cc: stable@dpdk.org
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
drivers/common/cnxk/roc_npc_parse.c

index 302ab66..b849326 100644 (file)
@@ -112,6 +112,7 @@ npc_parse_cpt_hdr(struct npc_parse_state *pst)
        info.hw_hdr_len = 0;
 
        /* Prepare for parsing the item */
+       info.def_mask = NULL;
        info.hw_mask = &hw_mask;
        info.len = pst->pattern->size;
        npc_get_hw_supp_mask(pst, &info, lid, lt);
@@ -149,6 +150,7 @@ npc_parse_higig2_hdr(struct npc_parse_state *pst)
        }
 
        /* Prepare for parsing the item */
+       info.def_mask = NULL;
        info.hw_mask = &hw_mask;
        info.len = pst->pattern->size;
        npc_get_hw_supp_mask(pst, &info, lid, lt);
@@ -198,6 +200,7 @@ npc_parse_la(struct npc_parse_state *pst)
        }
 
        /* Prepare for parsing the item */
+       info.def_mask = NULL;
        info.hw_mask = &hw_mask;
        info.len = sizeof(eth_item->hdr);
        npc_get_hw_supp_mask(pst, &info, lid, lt);
@@ -236,6 +239,7 @@ npc_parse_lb(struct npc_parse_state *pst)
        int nr_vlans = 0;
        int rc;
 
+       info.def_mask = NULL;
        info.spec = NULL;
        info.mask = NULL;
        info.def_mask = NULL;
@@ -396,12 +400,12 @@ npc_parse_mpls_label_stack(struct npc_parse_state *pst, int *flag)
         * pst->pattern points to first MPLS label. We only check
         * that subsequent labels do not have anything to match.
         */
+       info.def_mask = NULL;
        info.hw_mask = NULL;
        info.len = pattern->size;
        info.spec = NULL;
        info.mask = NULL;
        info.hw_hdr_len = 0;
-       info.def_mask = NULL;
 
        while (pattern->type == ROC_NPC_ITEM_TYPE_MPLS) {
                nr_labels++;
@@ -447,6 +451,7 @@ npc_parse_mpls(struct npc_parse_state *pst, int lid)
        info.len = pst->pattern->size;
        info.spec = NULL;
        info.mask = NULL;
+       info.def_mask = NULL;
        info.hw_hdr_len = 0;
 
        npc_get_hw_supp_mask(pst, &info, lid, lt);
@@ -547,6 +552,7 @@ npc_parse_lc(struct npc_parse_state *pst)
        if (pst->pattern->type == ROC_NPC_ITEM_TYPE_MPLS)
                return npc_parse_mpls(pst, NPC_LID_LC);
 
+       info.def_mask = NULL;
        info.hw_mask = &hw_mask;
        info.spec = NULL;
        info.mask = NULL;
@@ -640,10 +646,10 @@ npc_parse_ld(struct npc_parse_state *pst)
                        return npc_parse_mpls(pst, NPC_LID_LD);
                return 0;
        }
+       info.def_mask = NULL;
        info.hw_mask = &hw_mask;
        info.spec = NULL;
        info.mask = NULL;
-       info.def_mask = NULL;
        info.len = 0;
        info.hw_hdr_len = 0;
 
@@ -799,6 +805,7 @@ npc_parse_lf(struct npc_parse_state *pst)
        lflags = 0;
 
        /* No match support for vlan tags */
+       info.def_mask = NULL;
        info.hw_mask = NULL;
        info.len = pst->pattern->size;
        info.spec = NULL;
@@ -857,6 +864,7 @@ npc_parse_lg(struct npc_parse_state *pst)
        if (!pst->tunnel)
                return 0;
 
+       info.def_mask = NULL;
        info.hw_mask = &hw_mask;
        info.spec = NULL;
        info.mask = NULL;
@@ -893,6 +901,7 @@ npc_parse_lh(struct npc_parse_state *pst)
        if (!pst->tunnel)
                return 0;
 
+       info.def_mask = NULL;
        info.hw_mask = &hw_mask;
        info.spec = NULL;
        info.mask = NULL;