From: Somnath Kotur <somnath.ko...@broadcom.com>

Now that vnics are created only as part of the flow creation cmds
and not during init, we cannot rely on iterating only through
'nr_vnics'. We need to sweep all the vnics by using 'max_vnics'
otherwise a vnic with a stale 'rx_queue_cnt' might be left lingering
post a port stop/start operation. This could lead to a segfault.
This change is required because of the recent fix made by commit to
"fix flow creation with non-consecutive group ids".

Fixes: bab0a1f2ed4b ("net/bnxt: fix flow creation with non-consecutive group 
ids")

Signed-off-by: Somnath Kotur <somnath.ko...@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khapa...@broadcom.com>
---
 drivers/net/bnxt/bnxt_vnic.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c
index 52a4badfc..104342e13 100644
--- a/drivers/net/bnxt/bnxt_vnic.c
+++ b/drivers/net/bnxt/bnxt_vnic.c
@@ -75,12 +75,13 @@ struct bnxt_vnic_info *bnxt_alloc_vnic(struct bnxt *bp)
 
 void bnxt_free_all_vnics(struct bnxt *bp)
 {
-       struct bnxt_vnic_info *temp;
+       struct bnxt_vnic_info *vnic;
        unsigned int i;
 
-       for (i = 0; i < bp->nr_vnics; i++) {
-               temp = &bp->vnic_info[i];
-               STAILQ_INSERT_TAIL(&bp->free_vnic_list, temp, next);
+       for (i = 0; i < bp->max_vnics; i++) {
+               vnic = &bp->vnic_info[i];
+               STAILQ_INSERT_TAIL(&bp->free_vnic_list, vnic, next);
+               vnic->rx_queue_cnt = 0;
        }
 }
 
-- 
2.21.0 (Apple Git-122.2)

Reply via email to