From 25ee8cca07e4786f8a5fdce0363c8c862a2b918d Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sat, 23 Aug 2008 18:22:49 +0000 Subject: [PATCH] Handle the error case properly for device_get_children. --- sys/dev/sound/usb/uaudio.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c index 5e446ef60a85..758d6cdca7a9 100644 --- a/sys/dev/sound/usb/uaudio.c +++ b/sys/dev/sound/usb/uaudio.c @@ -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;