From c14c928ea9792f750e88d5cdbe7690cf93e62bba Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 8 Jun 2022 08:15:49 +0000 Subject: [PATCH] block: fix busy device checking in blk_drop_partitions again mainline inclusion from mainline-v5.7-rc1 commit cb6b771b05c3026a85ed4817c1b87c5e6f41d136 category: bugfix bugzilla: 186898, https://gitee.com/openeuler/kernel/issues/I5ALJL CVE: NA -------------------------------- The previous fix had an off by one in the bd_openers checking, counting the callers blkdev_get. Fixes: d3ef5536274f ("block: fix busy device checking in blk_drop_partitions") Reported-by: Qian Cai Signed-off-by: Christoph Hellwig Tested-by: Qian Cai Signed-off-by: Jens Axboe Signed-off-by: Li Nan Reviewed-by: Jason Yan Signed-off-by: Yongqiang Liu --- block/partition-generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/partition-generic.c b/block/partition-generic.c index 9e8a94761b57..1fa7aa82c768 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -464,7 +464,7 @@ static int drop_partitions(struct gendisk *disk, struct block_device *bdev) struct hd_struct *part; int res; - if (bdev->bd_part_count || bdev->bd_openers) + if (bdev->bd_part_count || bdev->bd_openers > 1) return -EBUSY; res = invalidate_partition(disk, 0); if (res) -- GitLab