btrfs: fix missing blkdev_put() call in btrfs_scan_one_device()
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Wed, 15 Dec 2021 10:38:43 +0000 (19:38 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Dec 2021 08:32:47 +0000 (09:32 +0100)
commit210ab4e3c03255d9f2ea06707fdd493f7562945c
treecbd8630fc86261e14cc28d78deffc9e416201b4e
parent8848395975bdd15572a042566aff2ac78a6895ee
btrfs: fix missing blkdev_put() call in btrfs_scan_one_device()

commit 4989d4a0aed3fb30f5b48787a689d7090de6f86d upstream.

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: 12659251ca5df ("btrfs: implement log-structured superblock for ZONED mode")
CC: stable@vger.kernel.org # 5.15+
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/volumes.c