Commit 8b52d8be authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe
Browse files

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Link: https://lore.kernel.org/r/20210623145908.92973-2-hch@lst.de


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 1033d103
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -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);
}