kobject_put vs module unload

Mikulas Patocka
2011-01-08T03:42:32Z

Hi

I'm looking at some kobject problem in device mapper and I came across
this problem:

According to kobject interface specification, If we embed a kobject into
the device structure, we shouldn't free the device structure when the
device is unloaded, but we should register a "release" callback in
kobj_type that will actually free the device structure.

What happens in this scenario?:

1) someone references a device kobject
2) the device is unloaded (but the device structure is still in memory
because of that reference)
3) the driver module is unloaded
4) the reference obtained at point 1) is dropped, kobject reference count
reaches zero and the release callback is called. But that callback points
to an unloaded module and causes a crash.

How is it solved? Am I missing something?

Mikulas