Skip to content

Commit

Permalink
loop: be paranoid on exit and prevent new additions / removals
Browse files Browse the repository at this point in the history
Be pedantic on removal as well and hold the mutex.
This should prevent uses of addition while we exit.

Signed-off-by: Luis Chamberlain <[email protected]>
Reviewed-by: Ming Lei <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
mcgrof authored and axboe committed Jun 24, 2020
1 parent a67549c commit 200f933
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/block/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -2404,13 +2404,17 @@ static void __exit loop_exit(void)

range = max_loop ? max_loop << part_shift : 1UL << MINORBITS;

mutex_lock(&loop_ctl_mutex);

idr_for_each(&loop_index_idr, &loop_exit_cb, NULL);
idr_destroy(&loop_index_idr);

blk_unregister_region(MKDEV(LOOP_MAJOR, 0), range);
unregister_blkdev(LOOP_MAJOR, "loop");

misc_deregister(&loop_misc);

mutex_unlock(&loop_ctl_mutex);
}

module_init(loop_init);
Expand Down

0 comments on commit 200f933

Please sign in to comment.