From 27bbab02b765aab221c5b395c7000fc3e9b4f868 Mon Sep 17 00:00:00 2001 From: archie Date: Sat, 15 Dec 2001 19:59:28 +0000 Subject: Fix access-after-free bug added in revision 1.31. Detected by: INVARIANTS MFC after: 2 days --- sys/pci/if_sis.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sys/pci/if_sis.c') diff --git a/sys/pci/if_sis.c b/sys/pci/if_sis.c index 81ec6c4..fb5435d 100644 --- a/sys/pci/if_sis.c +++ b/sys/pci/if_sis.c @@ -430,6 +430,7 @@ static device_t sis_find_bridge(dev) device_t *pci_children; int pci_childcount = 0; device_t *busp, *childp; + device_t child = NULL; int i, j; if ((pci_devclass = devclass_find("pci")) == NULL) @@ -444,16 +445,16 @@ static device_t sis_find_bridge(dev) j < pci_childcount; j++, childp++) { if (pci_get_vendor(*childp) == SIS_VENDORID && pci_get_device(*childp) == 0x0008) { - free(pci_devices, M_TEMP); - free(pci_children, M_TEMP); - return(*childp); + child = *childp; + goto done; } } } +done: free(pci_devices, M_TEMP); free(pci_children, M_TEMP); - return(NULL); + return(child); } static void sis_read_cmos(sc, dev, dest, off, cnt) -- cgit v1.1