diff options
author | dfr <dfr@FreeBSD.org> | 1998-11-13 09:39:37 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 1998-11-13 09:39:37 +0000 |
commit | bd083c1ec43e077fa66c511d033cb92e573b3a57 (patch) | |
tree | d342eb275f673b6fe26c4c3a89cf2df5c84b5d8c /sys | |
parent | 8ef2fc9dde7cc4ecc71a262069d286452f7a6005 (diff) | |
download | FreeBSD-src-bd083c1ec43e077fa66c511d033cb92e573b3a57.zip FreeBSD-src-bd083c1ec43e077fa66c511d033cb92e573b3a57.tar.gz |
A couple of fixes to device_delete_child() to delete all children of
the device and to free the device which is being deleted (not its
parent - oops).
Submitted by: Nick Hibma <nick.hibma@jrc.it>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/subr_bus.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 20fea6d..58ff2a2 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: subr_bus.c,v 1.7 1998/10/25 17:44:51 phk Exp $ + * $Id: subr_bus.c,v 1.8 1998/10/27 09:21:43 dfr Exp $ */ #include <sys/param.h> @@ -537,15 +537,23 @@ int device_delete_child(device_t dev, device_t child) { int error; + device_t grandchild; PDEBUG(("%s from %s", DEVICENAME(child), DEVICENAME(dev))); + /* remove children first */ + while ( (grandchild = TAILQ_FIRST(&child->children)) ) { + error = device_delete_child(child, grandchild); + if (error) + return error; + } + if (error = device_detach(child)) return error; if (child->devclass) devclass_delete_device(child->devclass, child); TAILQ_REMOVE(&dev->children, child, link); - free(dev, M_DEVBUF); + free(child, M_DEVBUF); return 0; } |