linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: Fix missing blkdev_put() call in btrfs_scan_one_device()
@ 2021-12-15 10:38 Shin'ichiro Kawasaki
  2021-12-15 13:20 ` Nikolay Borisov
  2021-12-15 15:08 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Shin'ichiro Kawasaki @ 2021-12-15 10:38 UTC (permalink / raw)
  To: linux-btrfs, David Sterba
  Cc: Naohiro Aota, Johannes Thumshirn, Damien Le Moal, Shinichiro Kawasaki

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")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Cc: stable@vger.kernel.org # 5.15+
---
 fs/btrfs/volumes.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 0997e3cd74e9..fd0ced829edb 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1370,8 +1370,10 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags,
 
 	bytenr_orig = btrfs_sb_offset(0);
 	ret = btrfs_sb_log_location_bdev(bdev, 0, READ, &bytenr);
-	if (ret)
-		return ERR_PTR(ret);
+	if (ret) {
+		device = ERR_PTR(ret);
+		goto error_bdev_put;
+	}
 
 	disk_super = btrfs_read_disk_super(bdev, bytenr, bytenr_orig);
 	if (IS_ERR(disk_super)) {
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: Fix missing blkdev_put() call in btrfs_scan_one_device()
  2021-12-15 10:38 [PATCH] btrfs: Fix missing blkdev_put() call in btrfs_scan_one_device() Shin'ichiro Kawasaki
@ 2021-12-15 13:20 ` Nikolay Borisov
  2021-12-15 15:08 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2021-12-15 13:20 UTC (permalink / raw)
  To: Shin'ichiro Kawasaki, linux-btrfs, David Sterba
  Cc: Naohiro Aota, Johannes Thumshirn, Damien Le Moal



On 15.12.21 г. 12:38, Shin'ichiro Kawasaki wrote:
> 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")
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> Cc: stable@vger.kernel.org # 5.15+
> ---

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: Fix missing blkdev_put() call in btrfs_scan_one_device()
  2021-12-15 10:38 [PATCH] btrfs: Fix missing blkdev_put() call in btrfs_scan_one_device() Shin'ichiro Kawasaki
  2021-12-15 13:20 ` Nikolay Borisov
@ 2021-12-15 15:08 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2021-12-15 15:08 UTC (permalink / raw)
  To: Shin'ichiro Kawasaki
  Cc: linux-btrfs, David Sterba, Naohiro Aota, Johannes Thumshirn,
	Damien Le Moal

On Wed, Dec 15, 2021 at 07:38:43PM +0900, Shin'ichiro Kawasaki wrote:
> 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")
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> Cc: stable@vger.kernel.org # 5.15+

Added to misc-next, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-15 15:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-15 10:38 [PATCH] btrfs: Fix missing blkdev_put() call in btrfs_scan_one_device() Shin'ichiro Kawasaki
2021-12-15 13:20 ` Nikolay Borisov
2021-12-15 15:08 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).