Date: Sat, 21 Jan 2006 23:48:22 -0700 (MST) From: "M. Warner Losh" <imp@bsdimp.com> To: PeterJeremy@optushome.com.au Cc: freebsd-current@freebsd.org Subject: Re: Panic due to deleting devices twice Message-ID: <20060121.234822.107142930.imp@bsdimp.com> In-Reply-To: <20060121070706.GA32444@cirb503493.alcatel.com.au> References: <20060121070706.GA32444@cirb503493.alcatel.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
In message: <20060121070706.GA32444@cirb503493.alcatel.com.au> Peter Jeremy <PeterJeremy@optushome.com.au> writes: : When deleting a device (using device_delete_child()), all its child : devices are recursively deleted and then device_detach() is called. I think that order is backwards. We should detach the device prior to deleting the device... : Looking at device_detach(), it appears that the solution is to create : a bus_child_detached method to inform the parent that a child is being : destroyed so it can invalidate cached pointers to that child. In : practice, there are only 5 bus_child_detached methods (isa, ed, : pccard, cbb and usb), though there are far more device types attached : as children. We have this problem in a number of places in the tree (mostly network drivers). However, most of the real bus drivers don't cache pointers to children, so we've not seen this much at the present time. : Looking at the iicsmb code, it appears that iicbb and iicsmb both : cache and explicitly delete child devices and therefore both need : bus_child_detached methods. Is this correct? Is there a simpler : alternative? Yes. This is how ed deals: static void ed_child_detached(device_t dev, device_t child) { struct ed_softc *sc; sc = device_get_softc(dev); if (child == sc->miibus) sc->miibus = NULL; } Warner
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060121.234822.107142930.imp>