* [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
* Re: [PATCH] btrfs: fix a memory leak in read_zone_info
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:19 ` David Sterba
2 siblings, 0 replies; 10+ messages in thread
From: Johannes Thumshirn @ 2022-07-01 5:59 UTC (permalink / raw)
To: Christoph Hellwig, clm, josef, dsterba; +Cc: linux-btrfs, Naohiro Aota
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] btrfs: fix a memory leak in read_zone_info
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:19 ` David Sterba
2 siblings, 1 reply; 10+ messages in thread
From: Anand Jain @ 2022-07-03 1:41 UTC (permalink / raw)
To: Christoph Hellwig, clm, josef, dsterba; +Cc: linux-btrfs, naohiro.aota
On 01/07/2022 00:03, Christoph Hellwig wrote:
> 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;
> }
>
Why not call put also during return -EINVAL a few lines above?
if (bioc->map_type & BTRFS_BLOCK_GROUP_RAID56_MASK)
return -EINVAL;
-Anand
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] btrfs: fix a memory leak in read_zone_info
2022-07-03 1:41 ` Anand Jain
@ 2022-07-07 17:22 ` David Sterba
2022-07-07 17:34 ` Christoph Hellwig
0 siblings, 1 reply; 10+ messages in thread
From: David Sterba @ 2022-07-07 17:22 UTC (permalink / raw)
To: Anand Jain
Cc: Christoph Hellwig, clm, josef, dsterba, linux-btrfs, naohiro.aota
On Sun, Jul 03, 2022 at 09:41:07AM +0800, Anand Jain wrote:
> On 01/07/2022 00:03, Christoph Hellwig wrote:
> > 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;
> > }
> >
>
> Why not call put also during return -EINVAL a few lines above?
>
> if (bioc->map_type & BTRFS_BLOCK_GROUP_RAID56_MASK)
> return -EINVAL;
Actually yes, it should be here as well, otherwise this would leak.
RAID56 + zoned combination is rejected much earlier so this would not
happen in practice.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] btrfs: fix a memory leak in read_zone_info
2022-07-07 17:22 ` David Sterba
@ 2022-07-07 17:34 ` Christoph Hellwig
2022-07-08 12:46 ` David Sterba
0 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2022-07-07 17:34 UTC (permalink / raw)
To: dsterba, Anand Jain, Christoph Hellwig, clm, josef, dsterba,
linux-btrfs, naohiro.aota
On Thu, Jul 07, 2022 at 07:22:41PM +0200, David Sterba wrote:
> Actually yes, it should be here as well, otherwise this would leak.
> RAID56 + zoned combination is rejected much earlier so this would not
> happen in practice.
A version with that fixed is already out on the list, just pick that
one up instead.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] btrfs: fix a memory leak in read_zone_info
2022-07-07 17:34 ` Christoph Hellwig
@ 2022-07-08 12:46 ` David Sterba
0 siblings, 0 replies; 10+ messages in thread
From: David Sterba @ 2022-07-08 12:46 UTC (permalink / raw)
To: Christoph Hellwig
Cc: dsterba, Anand Jain, clm, josef, dsterba, linux-btrfs, naohiro.aota
On Thu, Jul 07, 2022 at 07:34:03PM +0200, Christoph Hellwig wrote:
> On Thu, Jul 07, 2022 at 07:22:41PM +0200, David Sterba wrote:
> > Actually yes, it should be here as well, otherwise this would leak.
> > RAID56 + zoned combination is rejected much earlier so this would not
> > happen in practice.
>
> A version with that fixed is already out on the list, just pick that
> one up instead.
Right, I did not notice it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] btrfs: fix a memory leak in read_zone_info
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:19 ` David Sterba
2 siblings, 0 replies; 10+ messages in thread
From: David Sterba @ 2022-07-07 17:19 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: clm, josef, dsterba, linux-btrfs, naohiro.aota
On Thu, Jun 30, 2022 at 06:03:19PM +0200, Christoph Hellwig wrote:
> 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>
Added to misc-next, thanks.
^ permalink raw reply [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
* Re: [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
1 sibling, 0 replies; 10+ messages in thread
From: Anand Jain @ 2022-07-07 22:39 UTC (permalink / raw)
To: Christoph Hellwig, clm, josef, dsterba, naohiro.aota; +Cc: linux-btrfs
On 04/07/2022 16:10, Christoph Hellwig wrote:
> 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>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
> ---
> 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;
> }
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [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
1 sibling, 0 replies; 10+ messages in thread
From: David Sterba @ 2022-07-08 12:46 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: clm, josef, dsterba, naohiro.aota, linux-btrfs
On Mon, Jul 04, 2022 at 10:10:22AM +0200, Christoph Hellwig wrote:
> 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>
Added to misc-next, thanks.
^ permalink raw reply [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.