net/bnxt: fix checking VNIC in shutdown path
authorSomnath Kotur <somnath.kotur@broadcom.com>
Fri, 11 Sep 2020 01:56:02 +0000 (18:56 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 18 Sep 2020 16:55:12 +0000 (18:55 +0200)
Add a couple of NULL pointer checks in bnxt_free_all_filters()
and bnxt_free_vnics() respectively to guard against certain error
injection/recovery scenarios where it was found that the application
was crashing with the bp->vnic_info pointer being NULL.

Fixes: 51fafb89a9a0 ("net/bnxt: get rid of ff pools and use VNIC info array")
Cc: stable@dpdk.org
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/bnxt_filter.c
drivers/net/bnxt/bnxt_vnic.c

index d822ff6..6d85983 100644 (file)
@@ -81,6 +81,15 @@ void bnxt_free_all_filters(struct bnxt *bp)
        struct bnxt_filter_info *filter, *temp_filter;
        unsigned int i;
 
+       for (i = 0; i < bp->pf->max_vfs; i++) {
+               STAILQ_FOREACH(filter, &bp->pf->vf_info[i].filter, next) {
+                       bnxt_hwrm_clear_l2_filter(bp, filter);
+               }
+       }
+
+       if (bp->vnic_info == NULL)
+               return;
+
        for (i = 0; i < bp->nr_vnics; i++) {
                vnic = &bp->vnic_info[i];
                filter = STAILQ_FIRST(&vnic->filter);
@@ -95,11 +104,6 @@ void bnxt_free_all_filters(struct bnxt *bp)
                STAILQ_INIT(&vnic->filter);
        }
 
-       for (i = 0; i < bp->pf->max_vfs; i++) {
-               STAILQ_FOREACH(filter, &bp->pf->vf_info[i].filter, next) {
-                       bnxt_hwrm_clear_l2_filter(bp, filter);
-               }
-       }
 }
 
 void bnxt_free_filter_mem(struct bnxt *bp)
index 326c0d1..9a135ae 100644 (file)
@@ -78,6 +78,9 @@ void bnxt_free_all_vnics(struct bnxt *bp)
        struct bnxt_vnic_info *vnic;
        unsigned int i;
 
+       if (bp->vnic_info == NULL)
+               return;
+
        for (i = 0; i < bp->max_vnics; i++) {
                vnic = &bp->vnic_info[i];
                STAILQ_INSERT_TAIL(&bp->free_vnic_list, vnic, next);