Message ID | 20220630160319.2550384-1-hch@lst.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: fix a memory leak in read_zone_info | expand |
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
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
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.
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.
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.
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.
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; }
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(-)