]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
block: clear ->slave_dir when dropping the main slave_dir reference
authorChristoph Hellwig <hch@lst.de>
Tue, 15 Nov 2022 14:10:45 +0000 (22:10 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 16 Nov 2022 22:19:53 +0000 (15:19 -0700)
Zero out the pointer to ->slave_dir so that the holder code doesn't
incorrectly treat the object as alive when add_disk failed or after
del_gendisk was called.

Fixes: 89f871af1b26 ("dm: delay registering the gendisk")
Reported-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Mike Snitzer <snitzer@kernel.org>
Link: https://lore.kernel.org/r/20221115141054.1051801-2-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/genhd.c

index 09cde914e0548dd99b1d04370aaaa231e07ba7e0..6271ad06ed07e6fb2a2f9908512ee9413d6c7671 100644 (file)
@@ -528,6 +528,7 @@ out_unregister_queue:
        blk_unregister_queue(disk);
 out_put_slave_dir:
        kobject_put(disk->slave_dir);
+       disk->slave_dir = NULL;
 out_put_holder_dir:
        kobject_put(disk->part0->bd_holder_dir);
 out_del_integrity:
@@ -629,6 +630,7 @@ void del_gendisk(struct gendisk *disk)
 
        kobject_put(disk->part0->bd_holder_dir);
        kobject_put(disk->slave_dir);
+       disk->slave_dir = NULL;
 
        part_stat_set_all(disk->part0, 0);
        disk->part0->bd_stamp = 0;