Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Jan 2006 16:18:03 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-current@freebsd.org
Cc:        Peter Jeremy <PeterJeremy@optushome.com.au>
Subject:   Re: Panic due to deleting devices twice
Message-ID:  <200601231618.04949.jhb@freebsd.org>
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
On Saturday 21 January 2006 02:07, Peter Jeremy wrote:
> When deleting a device (using device_delete_child()), all its child
> devices are recursively deleted and then device_detach() is called.
>
> In the case of iicsmb, this causes a panic because iicsmb_detach()
> also calls device_delete_child() on the smbus child it has cached in
> its softc.  By this time that child has been destroyed.
>
> 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.
>
> 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?

Can they just call bus_generic_detach() instead and not call 
device_delete_child()?

-- 
John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200601231618.04949.jhb>