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

Loading…
Cancel
Save