Skip to content

Commit f73b597

Browse files
mcgrofgregkh
authored andcommitted
loop: be paranoid on exit and prevent new additions / removals
[ Upstream commit 200f933 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 29e1dfc commit f73b597

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/block/loop.c

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

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

2282+
mutex_lock(&loop_ctl_mutex);
2283+
22822284
idr_for_each(&loop_index_idr, &loop_exit_cb, NULL);
22832285
idr_destroy(&loop_index_idr);
22842286

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

22882290
misc_deregister(&loop_misc);
2291+
2292+
mutex_unlock(&loop_ctl_mutex);
22892293
}
22902294

22912295
module_init(loop_init);

0 commit comments

Comments
 (0)