cvs commit: src/sys/pci agp.c
John Baldwin
jhb at freebsd.org
Tue Jan 17 08:10:20 PST 2006
On Tuesday 17 January 2006 06:51, Doug Rabson wrote:
> On 20 Dec 2005, at 21:06, John Baldwin wrote:
> > jhb 2005-12-20 21:06:43 UTC
> >
> > FreeBSD src repository
> >
> > Modified files:
> > sys/pci agp.c
> > Log:
> > Change the agp_find_device() to return the first agp device that
> > has been
> > attached to a driver rather than always returning agp0.
>
> According to Coverity, this introduces a memory leak
> (devclass_get_devices() allocates memory).
That it does. How about this fix:
Index: pci/agp.c
===================================================================
RCS file: /usr/cvs/src/sys/pci/agp.c,v
retrieving revision 1.50
diff -u -r1.50 agp.c
--- pci/agp.c 20 Dec 2005 21:06:43 -0000 1.50
+++ pci/agp.c 17 Jan 2006 16:10:20 -0000
@@ -830,18 +830,22 @@
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
--
John Baldwin <jhb at FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" = http://www.FreeBSD.org
More information about the cvs-src
mailing list