Skip to content

Commit

Permalink
loop: reorder loop_exit
Browse files Browse the repository at this point in the history
Unregister the misc and blockdevice first to prevent further access,
and only then iterate to remove the devices.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Chaitanya Kulkarni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Jun 30, 2021
1 parent 1033d10 commit 8b52d8b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/block/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 8b52d8b

Please sign in to comment.