Browse Source

[rtl818x] Fix resource leak on error path

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 years ago
parent
commit
ce240c8c2d
1 changed files with 6 additions and 2 deletions
  1. 6
    2
      src/drivers/net/rtl818x/rtl818x.c

+ 6
- 2
src/drivers/net/rtl818x/rtl818x.c View File

@@ -663,7 +663,8 @@ int rtl818x_probe(struct pci_device *pdev )
663 663
 	hwinfo = zalloc(sizeof(*hwinfo));
664 664
 	if (!hwinfo) {
665 665
 		DBG("rtl818x: hwinfo alloc failed\n");
666
-		return -ENOMEM;
666
+		err = -ENOMEM;
667
+		goto err_alloc_hwinfo;
667 668
 	}
668 669
 
669 670
 	adjust_pci_device(pdev);
@@ -671,7 +672,8 @@ int rtl818x_probe(struct pci_device *pdev )
671 672
 	dev = net80211_alloc(sizeof(*priv));
672 673
 	if (!dev) {
673 674
 		DBG("rtl818x: net80211 alloc failed\n");
674
-		return -ENOMEM;
675
+		err = -ENOMEM;
676
+		goto err_alloc_dev;
675 677
 	}
676 678
 
677 679
 	priv = dev->priv;
@@ -816,7 +818,9 @@ int rtl818x_probe(struct pci_device *pdev )
816 818
  err_free_dev:
817 819
 	pci_set_drvdata(pdev, NULL);
818 820
 	net80211_free(dev);
821
+ err_alloc_dev:
819 822
 	free(hwinfo);
823
+ err_alloc_hwinfo:
820 824
 	return err;
821 825
 }
822 826
 

Loading…
Cancel
Save