]> git.baikalelectronics.ru Git - kernel.git/commit
block: delay freeing the gendisk
authorChristoph Hellwig <hch@lst.de>
Thu, 22 Jul 2021 07:53:54 +0000 (09:53 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 28 Jul 2021 01:35:47 +0000 (19:35 -0600)
commit485d931bd52fa7b059c209aa39b6a8e63cafabfb
treec3ac4c16cb0f62c1e3d01a087b51ad69a87257a5
parent97a13a4609034136428c009833db26d5968db740
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: 0f711687d915 ("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>
Link: https://lore.kernel.org/r/20210722075402.983367-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/genhd.c
fs/block_dev.c