Unregister the misc and blockdevice first to prevent further access,
and only then iterate to remove the devices. Also only take
loop_ctl_mutex for the remove action that it actually serialises.
Signed-off-by: Christoph Hellwig <hch@lst.de>
static void __exit loop_exit(void)
{
- mutex_lock(&loop_ctl_mutex);
-
- idr_for_each(&loop_index_idr, &loop_exit_cb, NULL);
- idr_destroy(&loop_index_idr);
-
unregister_blkdev(LOOP_MAJOR, "loop");
-
misc_deregister(&loop_misc);
+ mutex_lock(&loop_ctl_mutex);
+ idr_for_each(&loop_index_idr, &loop_exit_cb, NULL);
mutex_unlock(&loop_ctl_mutex);
+
+ idr_destroy(&loop_index_idr);
}
module_init(loop_init);