]> www.infradead.org Git - users/hch/block.git/commit
block: delay freeing the gendisk
authorChristoph Hellwig <hch@lst.de>
Fri, 16 Jul 2021 09:49:02 +0000 (11:49 +0200)
committerChristoph Hellwig <hch@lst.de>
Thu, 22 Jul 2021 07:50:54 +0000 (09:50 +0200)
commita798f76f9f7ced913b8490918d5bb5711c460051
treead9bf1dbf16f110991b02bc96fdf6a8dc7aa798f
parent3d5895cd351757f69c9a66fb5fc8cf19f454d773
block: delay freeing the gendisk

blkdev_get_no_open acquires a reference to the block_device through
the block device inode and then tries to acquire a device model
reference to the gendisk.  But at this point the disk migh already
be freed (although the race is free).  Fix this by only freeing the
gendisk from the whole device bdevs ->free_inode callback as well.

Fixes: 22ae8ce8b892 ("block: simplify bdev/disk lookup in blkdev_get")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
block/genhd.c
fs/block_dev.c