kobject_put vs module unload

From: Mikulas Patocka
Date: Fri Jan 07 2011 - 22:42:49 EST


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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/