[ofa-general] [PATCH 2.6.27] ib/cm: free cm_device structure
Hefty, Sean
sean.hefty at intel.com
Mon Aug 25 15:34:44 PDT 2008
>Is this really correct? Couldn't something (eg an open file from sysfs)
>still have a reference to cm_dev->device even after device_unregister()
>returns, in which case this ends up freeing an object that's still live?
I asked myself the same question. and I think this is okay. I'd appreciate if anyone else could review the changes though; the most relevant pieces of code are in cm.c immediately before and after cm_add_one().
The CM counter sysfs files are created off the cm_port object, which is allocated separately, and is freed through the kobject .release method. The cm_port object has a pointer to cm_dev, but only references it during typical CM operations (sending messages, creating reply AVs, etc.)
The cm_port does make a reference to cm_dev->device->kobj when calling kobject_init_and_add(), but the lifetime for cm_dev->device->kobj should be managed separately from cm_dev.
- Sean
More information about the general
mailing list