Skip to content

Commit 200f933

Browse files
mcgrofaxboe
authored andcommitted
loop: be paranoid on exit and prevent new additions / removals
Be pedantic on removal as well and hold the mutex. This should prevent uses of addition while we exit. Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent a67549c commit 200f933

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/block/loop.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,13 +2404,17 @@ static void __exit loop_exit(void)
24042404

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

2407+
mutex_lock(&loop_ctl_mutex);
2408+
24072409
idr_for_each(&loop_index_idr, &loop_exit_cb, NULL);
24082410
idr_destroy(&loop_index_idr);
24092411

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

24132415
misc_deregister(&loop_misc);
2416+
2417+
mutex_unlock(&loop_ctl_mutex);
24142418
}
24152419

24162420
module_init(loop_init);

0 commit comments

Comments
 (0)