All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: fix a memory leak in read_zone_info
@ 2022-06-30 16:03 Christoph Hellwig
  2022-07-01  5:59 ` Johannes Thumshirn
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Christoph Hellwig @ 2022-06-30 16:03 UTC (permalink / raw)
  To: clm, josef, dsterba; +Cc: linux-btrfs, naohiro.aota

Don't leak the bioc on normal completion.

Fixes: 7db1c5d14dcd ("btrfs: zoned: support dev-replace in zoned filesystems")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/zoned.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 7a0f8fa448006..e92bd5582cab3 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1759,7 +1759,7 @@ static int read_zone_info(struct btrfs_fs_info *fs_info, u64 logical,
 		break;
 	}
 	memalloc_nofs_restore(nofs_flag);
-
+	btrfs_put_bioc(bioc);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH] btrfs: fix a memory leak in read_zone_info
@ 2022-07-04  8:10 Christoph Hellwig
  2022-07-07 22:39 ` Anand Jain
  2022-07-08 12:46 ` David Sterba
  0 siblings, 2 replies; 10+ messages in thread
From: Christoph Hellwig @ 2022-07-04  8:10 UTC (permalink / raw)
  To: clm, josef, dsterba, naohiro.aota; +Cc: linux-btrfs

Don't leak the bioc on normal completion or when finding a parity
raid extent.

Fixes: 7db1c5d14dcd ("btrfs: zoned: support dev-replace in zoned filesystems")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/zoned.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 7a0f8fa448006..46e6c70217e08 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1735,12 +1735,14 @@ static int read_zone_info(struct btrfs_fs_info *fs_info, u64 logical,
 	ret = btrfs_map_sblock(fs_info, BTRFS_MAP_GET_READ_MIRRORS, logical,
 			       &mapped_length, &bioc);
 	if (ret || !bioc || mapped_length < PAGE_SIZE) {
-		btrfs_put_bioc(bioc);
-		return -EIO;
+		ret = -EIO;
+		goto out_put_bioc;
 	}
 
-	if (bioc->map_type & BTRFS_BLOCK_GROUP_RAID56_MASK)
-		return -EINVAL;
+	if (bioc->map_type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
+		ret = -EINVAL;
+		goto out_put_bioc;
+	}
 
 	nofs_flag = memalloc_nofs_save();
 	nmirrors = (int)bioc->num_stripes;
@@ -1760,6 +1762,8 @@ static int read_zone_info(struct btrfs_fs_info *fs_info, u64 logical,
 	}
 	memalloc_nofs_restore(nofs_flag);
 
+out_put_bioc:
+	btrfs_put_bioc(bioc);
 	return ret;
 }
 
-- 
2.30.2


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

end of thread, other threads:[~2022-07-08 12:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30 16:03 [PATCH] btrfs: fix a memory leak in read_zone_info Christoph Hellwig
2022-07-01  5:59 ` Johannes Thumshirn
2022-07-03  1:41 ` Anand Jain
2022-07-07 17:22   ` David Sterba
2022-07-07 17:34     ` Christoph Hellwig
2022-07-08 12:46       ` David Sterba
2022-07-07 17:19 ` David Sterba
2022-07-04  8:10 Christoph Hellwig
2022-07-07 22:39 ` Anand Jain
2022-07-08 12:46 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.