All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: Christoph Hellwig <hch@lst.de>,
	clm@fb.com, josef@toxicpanda.com, dsterba@suse.com,
	naohiro.aota@wdc.com
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: fix a memory leak in read_zone_info
Date: Fri, 8 Jul 2022 06:39:10 +0800	[thread overview]
Message-ID: <5bac8a23-0f53-c671-81bb-376557eff2ae@oracle.com> (raw)
In-Reply-To: <20220704081022.27512-1-hch@lst.de>

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;
>   }
>   


  reply	other threads:[~2022-07-07 22:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-04  8:10 [PATCH] btrfs: fix a memory leak in read_zone_info Christoph Hellwig
2022-07-07 22:39 ` Anand Jain [this message]
2022-07-08 12:46 ` David Sterba
  -- strict thread matches above, loose matches on Subject: below --
2022-06-30 16:03 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5bac8a23-0f53-c671-81bb-376557eff2ae@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=hch@lst.de \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.