bnxt_en: free hwrm resources, if driver probe fails.
authorVenkat Duvvuru <[email protected]>
Fri, 5 Oct 2018 04:26:02 +0000 (00:26 -0400)
committerDavid S. Miller <[email protected]>
Fri, 5 Oct 2018 04:41:16 +0000 (21:41 -0700)
When the driver probe fails, all the resources that were allocated prior
to the failure must be freed. However, hwrm dma response memory is not
getting freed.

This patch fixes the problem described above.

Fixes: c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.")
Signed-off-by: Venkat Duvvuru <[email protected]>
Signed-off-by: Michael Chan <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
drivers/net/ethernet/broadcom/bnxt/bnxt.c

index 2564a92dcb0268b7f3f52b67f8c2c6e804c544f3..3718984a8185b414ed48818947ce661e44227ed3 100644 (file)
@@ -3017,10 +3017,11 @@ static void bnxt_free_hwrm_resources(struct bnxt *bp)
 {
        struct pci_dev *pdev = bp->pdev;
 
-       dma_free_coherent(&pdev->dev, PAGE_SIZE, bp->hwrm_cmd_resp_addr,
-                         bp->hwrm_cmd_resp_dma_addr);
-
-       bp->hwrm_cmd_resp_addr = NULL;
+       if (bp->hwrm_cmd_resp_addr) {
+               dma_free_coherent(&pdev->dev, PAGE_SIZE, bp->hwrm_cmd_resp_addr,
+                                 bp->hwrm_cmd_resp_dma_addr);
+               bp->hwrm_cmd_resp_addr = NULL;
+       }
 }
 
 static int bnxt_alloc_hwrm_resources(struct bnxt *bp)
@@ -9057,6 +9058,7 @@ init_err_cleanup_tc:
        bnxt_clear_int_mode(bp);
 
 init_err_pci_clean:
+       bnxt_free_hwrm_resources(bp);
        bnxt_cleanup_pci(bp);
 
 init_err_free: