Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: Zach Brown <zab@redhat.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: fix btrfs_cont_expand() freeing IS_ERR em
Date: Tue, 08 Jan 2013 13:46:56 -0600	[thread overview]
Message-ID: <50EC77B0.3050400@redhat.com> (raw)
In-Reply-To: <1357673878-25591-1-git-send-email-zab@redhat.com>

On 1/8/13 1:37 PM, Zach Brown wrote:
> btrfs_cont_expand() tries to free an IS_ERR em as it gets an error from
> btrfs_get_extent() and breaks out of its loop.
> 
> An instance of -EEXIST was reported in the wild:
> 
>   https://bugzilla.redhat.com/show_bug.cgi?id=874407
> 
> I have no idea if that -EEXIST is surprising, or not.  Regardless, this
> error handling should be cleaned up to handle other reasonable errors
> (ENOMEM, EIO; whatever).
> 
> This seemed to be the only buggy freeing of the relatively rare IS_ERR
> em so I opted to fix the caller rather than teach free_extent_map() to
> use IS_ERR_OR_NULL().
> 
> Signed-off-by: Zach Brown <zab@redhat.com>

Looks good (maybe IS_ERR_OR_NULL would be more future-proof, but *shrug*)

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  fs/btrfs/inode.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index edd30ae..0bc7bb3 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -3690,6 +3690,7 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
>  				block_end - cur_offset, 0);
>  		if (IS_ERR(em)) {
>  			err = PTR_ERR(em);
> +			em = NULL;
>  			break;
>  		}
>  		last_byte = min(extent_map_end(em), block_end);
> 


  reply	other threads:[~2013-01-08 19:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-08 19:37 [PATCH] btrfs: fix btrfs_cont_expand() freeing IS_ERR em Zach Brown
2013-01-08 19:46 ` Eric Sandeen [this message]
2013-01-08 19:51   ` Zach Brown

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=50EC77B0.3050400@redhat.com \
    --to=sandeen@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=zab@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox