All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sheng Yong <shengyong1@huawei.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH] btrfs: trival fix of __btrfs_set_acl error handling
Date: Tue, 8 Sep 2015 08:46:42 +0000	[thread overview]
Message-ID: <1441702002-109706-1-git-send-email-shengyong1@huawei.com> (raw)

* If the allocation failed, don't free to free it, even though kfree
  allows to free a NULL pointer.
* If posix_acl_to_xattr() failed, cleanup the allocation and return
  the error directly.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
---
 fs/btrfs/acl.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
index 9a0124a..6d01d09 100644
--- a/fs/btrfs/acl.c
+++ b/fs/btrfs/acl.c
@@ -103,18 +103,18 @@ static int __btrfs_set_acl(struct btrfs_trans_handle *trans,
 	if (acl) {
 		size = posix_acl_xattr_size(acl->a_count);
 		value = kmalloc(size, GFP_NOFS);
-		if (!value) {
-			ret = -ENOMEM;
-			goto out;
-		}
+		if (!value)
+			return -ENOMEM;
 
 		ret = posix_acl_to_xattr(&init_user_ns, acl, value, size);
-		if (ret < 0)
-			goto out;
+		if (ret < 0) {
+			kfree(value);
+			return ret;
+		}
 	}
 
 	ret = __btrfs_setxattr(trans, inode, name, value, size, 0);
-out:
+
 	kfree(value);
 
 	if (!ret)
-- 
1.8.3.4


             reply	other threads:[~2015-09-08  8:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-08  8:46 Sheng Yong [this message]
2015-09-08  8:50 ` [PATCH] btrfs: trival fix of __btrfs_set_acl error handling Qu Wenruo
2015-09-08  9:02   ` Sheng Yong
2015-09-08 11:51     ` 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=1441702002-109706-1-git-send-email-shengyong1@huawei.com \
    --to=shengyong1@huawei.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.