Handle the error case properly for device_get_children.

This commit is contained in:
Warner Losh 2008-08-23 18:22:49 +00:00
parent 099ea4b570
commit 25ee8cca07
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=182076

View File

@ -699,8 +699,8 @@ USB_DETACH(uaudio)
err = bus_generic_detach(sc->sc_dev);
if (err == 0) {
device_get_children(sc->sc_dev, &devlist, &devcount);
if (err == 0 &&
device_get_children(sc->sc_dev, &devlist, &devcount) == 0) {
for (i = 0; devlist != NULL && i < devcount; i++) {
func = device_get_ivars(devlist[i]);
if (func != NULL && func->func == SCF_PCM &&
@ -710,8 +710,7 @@ USB_DETACH(uaudio)
device_delete_child(sc->sc_dev, devlist[i]);
}
}
if (devlist != NULL)
free(devlist, M_TEMP);
free(devlist, M_TEMP);
}
return err;