net/bnxt: fix crash in port stop while handling events
authorKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Thu, 20 Feb 2020 04:12:13 +0000 (09:42 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 21 Feb 2020 10:41:20 +0000 (11:41 +0100)
Check for bp->hwrm_cmd_resp_addr before using it in HWRM_PREP to avoid
segmentation fault when stop port and meanwhile receive events from FW.

Fixes: df6cd7c1f73a ("net/bnxt: handle reset notify async event from FW")
Cc: stable@dpdk.org
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/bnxt_hwrm.c

index acecf27..a9c9c72 100644 (file)
@@ -184,6 +184,10 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
  */
 #define HWRM_PREP(req, type, kong) do { \
        rte_spinlock_lock(&bp->hwrm_lock); \
+       if (bp->hwrm_cmd_resp_addr == NULL) { \
+               rte_spinlock_unlock(&bp->hwrm_lock); \
+               return -EACCES; \
+       } \
        memset(bp->hwrm_cmd_resp_addr, 0, bp->max_resp_len); \
        req.req_type = rte_cpu_to_le_16(HWRM_##type); \
        req.cmpl_ring = rte_cpu_to_le_16(-1); \
@@ -3096,9 +3100,9 @@ static void add_random_mac_if_needed(struct bnxt *bp,
        }
 }
 
-static void reserve_resources_from_vf(struct bnxt *bp,
-                                     struct hwrm_func_cfg_input *cfg_req,
-                                     int vf)
+static int reserve_resources_from_vf(struct bnxt *bp,
+                                    struct hwrm_func_cfg_input *cfg_req,
+                                    int vf)
 {
        struct hwrm_func_qcaps_input req = {0};
        struct hwrm_func_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
@@ -3132,6 +3136,8 @@ static void reserve_resources_from_vf(struct bnxt *bp,
        bp->max_ring_grps -= rte_le_to_cpu_16(resp->max_hw_ring_grps);
 
        HWRM_UNLOCK();
+
+       return 0;
 }
 
 int bnxt_hwrm_func_qcfg_current_vf_vlan(struct bnxt *bp, int vf)