All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liu Bo <bo.li.liu@oracle.com>
To: David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 3/3] btrfs: do proper error handling in btrfs_insert_xattr_item
Date: Tue, 21 Feb 2017 21:39:05 -0800	[thread overview]
Message-ID: <20170222053905.GC1497@lim.localdomain> (raw)
In-Reply-To: <e204841964263393974c193010c74648faa5a761.1487614974.git.dsterba@suse.com>

On Mon, Feb 20, 2017 at 07:25:06PM +0100, David Sterba wrote:
> The space check in btrfs_insert_xattr_item is duplicated in it's caller
> (do_setxattr) so we won't hit the BUG_ON. Continuing without any check
> could be disasterous so turn it to a proper error handling.
> 
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
>  fs/btrfs/dir-item.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
> index 724504a2d7ac..640801082533 100644
> --- a/fs/btrfs/dir-item.c
> +++ b/fs/btrfs/dir-item.c
> @@ -80,7 +80,8 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,
>  	struct extent_buffer *leaf;
>  	u32 data_size;
>  
> -	BUG_ON(name_len + data_len > BTRFS_MAX_XATTR_SIZE(root->fs_info));
> +	if (name_len + data_len > BTRFS_MAX_XATTR_SIZE(root->fs_info))
> +		return -ENOSPC;
>

Besides making it silent, how about adding a ASSERT to cry out?
(Although currently we'd never come into this case.)

Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

Thanks,

-liubo
>  	key.objectid = objectid;
>  	key.type = BTRFS_XATTR_ITEM_KEY;
> -- 
> 2.10.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2017-02-22  5:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-20 18:24 [PATCH 0/3] Remove some BUG_ONs David Sterba
2017-02-20 18:25 ` [PATCH 1/3] btrfs: remove BUG_ON from __tree_mod_log_insert David Sterba
2017-02-22  5:31   ` Liu Bo
2017-02-20 18:25 ` [PATCH 2/3] btrfs: handle allocation error in update_dev_stat_item David Sterba
2017-02-22  5:33   ` Liu Bo
2017-02-20 18:25 ` [PATCH 3/3] btrfs: do proper error handling in btrfs_insert_xattr_item David Sterba
2017-02-22  5:39   ` Liu Bo [this message]
2017-02-28 10:41     ` 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=20170222053905.GC1497@lim.localdomain \
    --to=bo.li.liu@oracle.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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.