Skip to content

Commit 4989d4a

Browse files
kawasakikdave
authored andcommitted
btrfs: fix missing blkdev_put() call in btrfs_scan_one_device()
The function btrfs_scan_one_device() calls blkdev_get_by_path() and blkdev_put() to get and release its target block device. However, when btrfs_sb_log_location_bdev() fails, blkdev_put() is not called and the block device is left without clean up. This triggered failure of fstests generic/085. Fix the failure path of btrfs_sb_log_location_bdev() to call blkdev_put(). Fixes: 1265925 ("btrfs: implement log-structured superblock for ZONED mode") CC: [email protected] # 5.15+ Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: Shin'ichiro Kawasaki <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 212a58f commit 4989d4a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/btrfs/volumes.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,8 +1370,10 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags,
13701370

13711371
bytenr_orig = btrfs_sb_offset(0);
13721372
ret = btrfs_sb_log_location_bdev(bdev, 0, READ, &bytenr);
1373-
if (ret)
1374-
return ERR_PTR(ret);
1373+
if (ret) {
1374+
device = ERR_PTR(ret);
1375+
goto error_bdev_put;
1376+
}
13751377

13761378
disk_super = btrfs_read_disk_super(bdev, bytenr, bytenr_orig);
13771379
if (IS_ERR(disk_super)) {

0 commit comments

Comments
 (0)