diff options
author | mav <mav@FreeBSD.org> | 2008-11-22 15:35:21 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2008-11-22 15:35:21 +0000 |
commit | 6acdbec25eb1f1b7790683ff3779e8243cccfefe (patch) | |
tree | 9aae38b3212b123afd184ad152c51c1d56c94067 /sys/dev/sound | |
parent | abfbbdbd081e0f32541bb1c74cd3a62fadc84f37 (diff) | |
download | FreeBSD-src-6acdbec25eb1f1b7790683ff3779e8243cccfefe.zip FreeBSD-src-6acdbec25eb1f1b7790683ff3779e8243cccfefe.tar.gz |
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
Diffstat (limited to 'sys/dev/sound')
-rw-r--r-- | sys/dev/sound/pci/hda/hdac.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/sys/dev/sound/pci/hda/hdac.c b/sys/dev/sound/pci/hda/hdac.c index 86d2c61..74a1d75 100644 --- a/sys/dev/sound/pci/hda/hdac.c +++ b/sys/dev/sound/pci/hda/hdac.c @@ -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); |