From: Kalesh AP Date: Thu, 20 Feb 2020 04:12:13 +0000 (+0530) Subject: net/bnxt: fix crash in port stop while handling events X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=0732bcb40f2f54397b70b6c63e0b1c7bdc03b8db;p=dpdk.git net/bnxt: fix crash in port stop while handling events 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 Reviewed-by: Ajit Khaparde --- diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index acecf27848..a9c9c7297c 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -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)