linux/drivers/block
Tetsuo Handa 4ddb85d366 ataflop: remove ataflop_probe_lock mutex
Commit bf9c0538e4 ("ataflop: use a separate gendisk for each media
format") introduced ataflop_probe_lock mutex, but forgot to unlock the
mutex when atari_floppy_init() (i.e. module loading) succeeded. This will
result in double lock deadlock if ataflop_probe() is called. Also,
unregister_blkdev() must not be called from atari_floppy_init() with
ataflop_probe_lock held when atari_floppy_init() failed, for
ataflop_probe() waits for ataflop_probe_lock with major_names_lock held
(i.e. AB-BA deadlock).

__register_blkdev() needs to be called last in order to avoid calling
ataflop_probe() when atari_floppy_init() is about to fail, for memory for
completing already-started ataflop_probe() safely will be released as soon
as atari_floppy_init() released ataflop_probe_lock mutex.

As with commit 8b52d8be86 ("loop: reorder loop_exit"),
unregister_blkdev() needs to be called first in order to avoid calling
ataflop_alloc_disk() from ataflop_probe() after del_gendisk() from
atari_floppy_exit().

By relocating __register_blkdev() / unregister_blkdev() as explained above,
we can remove ataflop_probe_lock mutex, for probe function and __exit
function are serialized by major_names_lock mutex.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Fixes: bf9c0538e4 ("ataflop: use a separate gendisk for each media format")
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Link: https://lore.kernel.org/r/20211103230437.1639990-11-mcgrof@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-11-04 05:48:50 -06:00
..
aoe block: aoe: fixup coccinelle warnings 2021-10-21 08:54:15 -06:00
drbd drbd: Fix double free problem in drbd_create_device 2021-11-04 05:45:41 -06:00
mtip32xx mtip32xx: Remove redundant 'flush_workqueue()' calls 2021-10-18 14:50:37 -06:00
null_blk null_blk: Fix handling of submit_queues and poll_queues attributes 2021-10-29 06:55:39 -06:00
paride pf: fix error codes in pf_init_unit() 2021-10-18 14:42:16 -06:00
rnbd rnbd: add error handling support for add_disk() 2021-10-21 09:00:56 -06:00
rsxx block/rsxx: add error handling support for add_disk() 2021-10-18 14:41:36 -06:00
xen-blkback isystem: trim/fixup stdarg.h and other headers 2021-08-19 09:02:55 +09:00
zram zram: replace fsync_bdev with sync_blockdev 2021-11-02 14:43:12 -06:00
amiflop.c amiflop: add error handling support for add_disk() 2021-10-18 14:41:37 -06:00
ataflop.c ataflop: remove ataflop_probe_lock mutex 2021-11-04 05:48:50 -06:00
brd.c block/brd: add error handling support for add_disk() 2021-10-30 11:07:40 -06:00
floppy.c floppy: add error handling support for add_disk() 2021-10-18 14:41:37 -06:00
Kconfig block: remove support for cryptoloop and the xor transfer 2021-10-22 08:34:58 -06:00
loop.c loop: Remove duplicate assignments 2021-11-04 05:47:53 -06:00
loop.h block: remove support for cryptoloop and the xor transfer 2021-10-22 08:34:58 -06:00
Makefile block: remove support for cryptoloop and the xor transfer 2021-10-22 08:34:58 -06:00
n64cart.c n64cart: add error handling support for add_disk() 2021-10-18 14:41:36 -06:00
nbd.c nbd: error out if socket index doesn't match in nbd_handle_reply() 2021-11-02 14:42:41 -06:00
pktcdvd.c pktcdvd: add error handling support for add_disk() 2021-10-18 14:41:36 -06:00
ps3disk.c ps3disk: add error handling support for add_disk() 2021-10-30 11:03:37 -06:00
ps3vram.c ps3vram: add error handling support for add_disk() 2021-10-30 11:03:37 -06:00
rbd_types.h libceph, rbd: replace zero-length array with flexible-array 2020-06-01 13:22:53 +02:00
rbd.c rbd: add add_disk() error handling 2021-10-18 14:41:37 -06:00
sunvdc.c block/sunvdc: add error handling support for add_disk() 2021-11-04 05:48:50 -06:00
swim3.c swim3: add missing major.h include 2021-10-18 14:42:44 -06:00
swim_asm.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
swim.c swim: add error handling support for add_disk() 2021-10-18 14:41:37 -06:00
sx8.c sx8: fix an error code in carm_init_one() 2021-10-18 14:42:30 -06:00
virtio_blk.c Revert "virtio-blk: Add validation for block size in config space" 2021-10-13 08:35:36 -04:00
xen-blkfront.c xen-blkfront: add error handling support for add_disk() 2021-10-21 09:00:56 -06:00
z2ram.c z2ram: add error handling support for add_disk() 2021-11-04 05:48:50 -06:00