From: Pan Bian <bianpan2016@163.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] gfs2: get rid of potential double free
Date: Mon, 26 Nov 2018 16:43:29 +0800 [thread overview]
Message-ID: <1543221809-86560-1-git-send-email-bianpan2016@163.com> (raw)
__gfs2_set_acl will not increase the reference count of acl if it fails.
In this case, posix_acl_release are called twice, one after
__gfs2_set_acl and one in the error handling block. This patch does not
release acl when __gfs2_set_acl fails.
Fixes: e01580bf9e4("gfs2: use generic posix ACL infrastructure")
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
fs/gfs2/inode.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 648f0ca..3a9041c 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -744,12 +744,13 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
the gfs2 structures. */
if (default_acl) {
error = __gfs2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
- posix_acl_release(default_acl);
+ if (!error)
+ posix_acl_release(default_acl);
}
- if (acl) {
+ if (acl && !error) {
+ error = __gfs2_set_acl(inode, acl, ACL_TYPE_ACCESS);
if (!error)
- error = __gfs2_set_acl(inode, acl, ACL_TYPE_ACCESS);
- posix_acl_release(acl);
+ posix_acl_release(acl);
}
if (error)
--
2.7.4
next reply other threads:[~2018-11-26 8:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-26 8:43 Pan Bian [this message]
2018-11-26 23:19 ` [Cluster-devel] [PATCH] gfs2: get rid of potential double free Andreas Gruenbacher
2018-11-27 0:40 ` PanBian
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=1543221809-86560-1-git-send-email-bianpan2016@163.com \
--to=bianpan2016@163.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;
as well as URLs for NNTP newsgroup(s).