Skip to content

Commit 428913b

Browse files
YuKuai-huaweiaxboe
authored andcommitted
block: fix wrong mode for blkdev_put() from disk_scan_partitions()
If disk_scan_partitions() is called with 'FMODE_EXCL', blkdev_get_by_dev() will be called without 'FMODE_EXCL', however, follow blkdev_put() is still called with 'FMODE_EXCL', which will cause 'bd_holders' counter to leak. Fix the problem by using the right mode for blkdev_put(). Reported-by: [email protected] Link: https://lore.kernel.org/lkml/[email protected]/T/ Tested-by: Julian Ruess <[email protected]> Fixes: e5cfefa ("block: fix scan partition for exclusively open device again") Signed-off-by: Yu Kuai <[email protected]> Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent fe15c26 commit 428913b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/genhd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ int disk_scan_partitions(struct gendisk *disk, fmode_t mode)
385385
if (IS_ERR(bdev))
386386
ret = PTR_ERR(bdev);
387387
else
388-
blkdev_put(bdev, mode);
388+
blkdev_put(bdev, mode & ~FMODE_EXCL);
389389

390390
if (!(mode & FMODE_EXCL))
391391
bd_abort_claiming(disk->part0, disk_scan_partitions);

0 commit comments

Comments
 (0)