> No, that's a race that would affect all modular drivers. Ideally, we would
> want to pin the module in memory on file open, then decrement the usage
> count on close. We could do this by adding a struct module field to struct
> driver_file_entry...
Hmm, adding anything to driver_file_entry will make it take twice
as much memory (it's 8 * sizeof(void*) now, allocated with kmalloc),
so I wouldn't want to have that if there is another way.
Adding an owner field to struct device is probably not enough if bridge
devices should be able to add files to their children. You would need
at least two struct module pointers then. Also, it requires every device
driver to initialize the owner field (at least one for its struct
device_driver).
An alternative might be a rw_semaphore in struct device that protects
the store and show callbacks in its files. On module unload, rmmod would
just have to wait on the semaphore if it is held by any readers.
Of course that protects only against the race between module unload
and file open, but there can be others of anyone does get_device without
incrementing the use counts for the right modules.
Arnd <><
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/