summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2022-11-15 22:10:45 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-12-31 13:32:12 +0100
commit475bdd75447acd9e771addf4c15d14a2d483d5c8 (patch)
tree8cef9fe978fa759474d7eb9b0246143e09a75a13 /block
parentd2845542a95336d4238e19e2a645f92ca16c472e (diff)
downloadlinux-stable-475bdd75447acd9e771addf4c15d14a2d483d5c8.tar.gz
linux-stable-475bdd75447acd9e771addf4c15d14a2d483d5c8.tar.bz2
linux-stable-475bdd75447acd9e771addf4c15d14a2d483d5c8.zip
block: clear ->slave_dir when dropping the main slave_dir reference
[ Upstream commit d90db3b1c8676bc88b4309c5a571333de2263b8e ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'block')
-rw-r--r--block/genhd.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 0f9769db2de8..647f7d8d8831 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -530,6 +530,7 @@ out_unregister_queue:
rq_qos_exit(disk->queue);
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;