svn commit: r185177 - head/sys/dev/sound/pci/hda
Alexander Motin
mav at FreeBSD.org
Sat Nov 22 07:35:22 PST 2008
Author: mav
Date: Sat Nov 22 15:35:21 2008
New Revision: 185177
URL: http://svn.freebsd.org/changeset/base/185177
Log:
Handle device_get_children() errors in more correct way.
We shouldn't detach until all children are surely destroyed.
Found with: Coverity Prevent(tm)
CID: 2137
Modified:
head/sys/dev/sound/pci/hda/hdac.c
Modified: head/sys/dev/sound/pci/hda/hdac.c
==============================================================================
--- head/sys/dev/sound/pci/hda/hdac.c Sat Nov 22 14:48:40 2008 (r185176)
+++ head/sys/dev/sound/pci/hda/hdac.c Sat Nov 22 15:35:21 2008 (r185177)
@@ -7571,17 +7571,20 @@ static int
hdac_detach(device_t dev)
{
struct hdac_softc *sc;
- device_t *devlist = NULL;
- int i, devcount;
+ device_t *devlist;
+ int i, devcount, error;
- sc = device_get_softc(dev);
-
- device_get_children(dev, &devlist, &devcount);
- for (i = 0; devlist != NULL && i < devcount; i++)
- device_delete_child(dev, devlist[i]);
- if (devlist != NULL)
- free(devlist, M_TEMP);
+ if ((error = device_get_children(dev, &devlist, &devcount)) != 0)
+ return (error);
+ for (i = 0; i < devcount; i++) {
+ if ((error = device_delete_child(dev, devlist[i])) != 0) {
+ free(devlist, M_TEMP);
+ return (error);
+ }
+ }
+ free(devlist, M_TEMP);
+ sc = device_get_softc(dev);
hdac_release_resources(sc);
return (0);
More information about the svn-src-head
mailing list