summaryrefslogtreecommitdiff
path: root/drivers/block/loop.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-06-23 17:59:00 +0300
committerJens Axboe <axboe@kernel.dk>2021-07-01 00:34:13 +0300
commit8b52d8be86d723085784317427d339528766d9a3 (patch)
treeefabe10cd08a438cae0f5857fe4bf838fbbad50f /drivers/block/loop.c
parent1033d103a9b795b41ca0bb90587047a65e2ed5ef (diff)
downloadlinux-8b52d8be86d723085784317427d339528766d9a3.tar.xz
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>
Diffstat (limited to 'drivers/block/loop.c')
-rw-r--r--drivers/block/loop.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index cc0e8c39a48b..0e96f8c422b3 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -2550,14 +2550,11 @@ static int loop_exit_cb(int id, void *ptr, void *data)
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);
+ idr_for_each(&loop_index_idr, &loop_exit_cb, NULL);
+ idr_destroy(&loop_index_idr);
mutex_unlock(&loop_ctl_mutex);
}