ethernet: sun: Free the coherent when failing in probing
authorZheyu Ma <zheyuma97@gmail.com>
Sat, 5 Mar 2022 14:55:04 +0000 (14:55 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 7 Mar 2022 11:32:22 +0000 (11:32 +0000)
When the driver fails to register net device, it should free the DMA
region first, and then do other cleanup.

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/sun/sunhme.c

index ad9029ae684851ff93eae56dd101ae93ce4b35ad..77e5dffb558f4a15ee78cb34e45959bd3bbf472a 100644 (file)
@@ -3146,7 +3146,7 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
        if (err) {
                printk(KERN_ERR "happymeal(PCI): Cannot register net device, "
                       "aborting.\n");
-               goto err_out_iounmap;
+               goto err_out_free_coherent;
        }
 
        pci_set_drvdata(pdev, hp);
@@ -3179,6 +3179,10 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 
        return 0;
 
+err_out_free_coherent:
+       dma_free_coherent(hp->dma_dev, PAGE_SIZE,
+                         hp->happy_block, hp->hblock_dvma);
+
 err_out_iounmap:
        iounmap(hp->gregs);