]> git.baikalelectronics.ru Git - kernel.git/commitdiff
loop: reduce loop_ctl_mutex coverage in loop_exit
authorChristoph Hellwig <hch@lst.de>
Wed, 23 Jun 2021 14:59:01 +0000 (16:59 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 30 Jun 2021 21:34:13 +0000 (15:34 -0600)
loop_ctl_mutex is only needed to iterate the IDR for removing the loop
devices, so reduce the coverage.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Link: https://lore.kernel.org/r/20210623145908.92973-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/loop.c

index 0e96f8c422b3d4460af3ca7f36f41ffa4e2af97e..4a3712e4cf120a00cd2b86661e3dbd89adaa581e 100644 (file)
@@ -2549,13 +2549,14 @@ static int loop_exit_cb(int id, void *ptr, void *data)
 
 static void __exit loop_exit(void)
 {
-       mutex_lock(&loop_ctl_mutex);
        unregister_blkdev(LOOP_MAJOR, "loop");
        misc_deregister(&loop_misc);
 
+       mutex_lock(&loop_ctl_mutex);
        idr_for_each(&loop_index_idr, &loop_exit_cb, NULL);
-       idr_destroy(&loop_index_idr);
        mutex_unlock(&loop_ctl_mutex);
+
+       idr_destroy(&loop_index_idr);
 }
 
 module_init(loop_init);