From 7f6555d455f978875b3f40b757762978fed9e05c Mon Sep 17 00:00:00 2001 From: jhb Date: Tue, 17 Jan 2006 17:02:45 +0000 Subject: Fix a memory leak I introduced with the hostb/vgapci stuff. Reported by: Coverity (via dfr's clue-bat) --- sys/pci/agp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'sys/pci') diff --git a/sys/pci/agp.c b/sys/pci/agp.c index 3986589..a0deb5f 100644 --- a/sys/pci/agp.c +++ b/sys/pci/agp.c @@ -830,18 +830,22 @@ agp_mmap(struct cdev *kdev, vm_offset_t offset, vm_paddr_t *paddr, int prot) device_t agp_find_device() { - device_t *children; + device_t *children, child; int i, count; if (!agp_devclass) return NULL; if (devclass_get_devices(agp_devclass, &children, &count) != 0) return NULL; + child = NULL; for (i = 0; i < count; i++) { - if (device_is_attached(children[i])) - return (children[i]); + if (device_is_attached(children[i])) { + child = children[i]; + break; + } } - return NULL; + free(children, M_TEMP); + return child; } enum agp_acquire_state -- cgit v1.1