2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-26 22:24:09 +08:00

loop: reorder loop_exit

Unregister the misc and blockdevice first to prevent further access,
and only then iterate to remove the devices.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Link: https://lore.kernel.org/r/20210623145908.92973-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Christoph Hellwig 2021-06-23 16:59:00 +02:00 committed by Jens Axboe
parent 1033d103a9
commit 8b52d8be86

View File

@ -2550,14 +2550,11 @@ static int loop_exit_cb(int id, void *ptr, void *data)
static void __exit loop_exit(void) static void __exit loop_exit(void)
{ {
mutex_lock(&loop_ctl_mutex); mutex_lock(&loop_ctl_mutex);
unregister_blkdev(LOOP_MAJOR, "loop");
misc_deregister(&loop_misc);
idr_for_each(&loop_index_idr, &loop_exit_cb, NULL); idr_for_each(&loop_index_idr, &loop_exit_cb, NULL);
idr_destroy(&loop_index_idr); idr_destroy(&loop_index_idr);
unregister_blkdev(LOOP_MAJOR, "loop");
misc_deregister(&loop_misc);
mutex_unlock(&loop_ctl_mutex); mutex_unlock(&loop_ctl_mutex);
} }