Panic due to deleting devices twice

From: Peter Jeremy <PeterJeremy_at_optushome.com.au>
Date: Sat, 21 Jan 2006 18:07:06 +1100
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?

-- 
Peter Jeremy
Received on Sat Jan 21 2006 - 06:07:10 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:51 UTC