HomeFreeBSD

iicbus: Use device_delete_children() instead of explicit child removal

Description

iicbus: Use device_delete_children() instead of explicit child removal

If the bus is detached and deleted by a call to device_delete_child() or
device_delete_children() on a device higher in the tree, I²C children
were already detached and deleted. So the device_t pointer stored in sc
points to freed memory: we must not try to delete it again.

By using device_delete_children(), we let subr_bus.c figure out if there
are children to take care of.

While here, make sure iicbus_detach() and iicoc_detach() call
device_delete_children() too, to be safe.

Reviewed by: jhb, imp
Approved by: jhb, imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D3926

Details

Provenance
dumbbellAuthored on
Reviewer
jhb
Differential Revision
D3926: iicbus: Use device_delete_children() instead of explicit child removal
Parents
rS289656: iicbus: Remove trailing whitespaces
Branches
Unknown
Tags
Unknown