bus device/ivars
Norbert Koch
nkoch at demig.de
Thu May 31 08:26:47 UTC 2012
Hello,
I have written a bus device driver
which itself is a pci driver. Child devices
may allocate resources from my bus device.
My bus device does the usual
management of resources through
the children's ivars.
My question is this:
The bus device mallocs the
children's ivars in bus_add_child
and frees the ivars in either
bus_detach or bus_child_detached.
The children are added in identify
methods through BUS_ADD_CHILD.
As I understand the code the bus device's
bus_child_detached method is called
in device_delete_child only if
the child device is already attached.
So, there seems to be a memory leak if
I delete the child device in either
identify or probe.
My current solution (not tested yet) is to
explicitly call BUS_CHILD_DETACHED
in the child device's code before
calling device_delete_child.
Is this the correct way or is
there a more elegant/cleaner solution?
I expected to find something like a
BUS_DELETE_CHILD method.
Thank you for any advice,
Norbert Koch
More information about the freebsd-hackers
mailing list