]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
bnxt_en: free hwrm resources, if driver probe fails.
authorVenkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Fri, 5 Oct 2018 04:26:02 +0000 (00:26 -0400)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:53:10 +0000 (19:53 -0600)
BugLink: https://bugs.launchpad.net/bugs/1836426
[ Upstream commit a2bf74f4e1b82395dad2b08d2a911d9151db71c1 ]

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 <venkatkumar.duvvuru@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/net/ethernet/broadcom/bnxt/bnxt.c

index f02f59156620266c44a8b968f36ea4c55dde4478..8a110aa2b3792ec8d08df209d14bac71a0ebdd9f 100644 (file)
@@ -2973,10 +2973,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;
+       }
        if (bp->hwrm_dbg_resp_addr) {
                dma_free_coherent(&pdev->dev, HWRM_DBG_REG_BUF_SIZE,
                                  bp->hwrm_dbg_resp_addr,
@@ -8267,6 +8268,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: