From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 6/6] GFS2: fix d_splice_alias() misuses
Date: Mon, 15 Sep 2014 10:32:48 +0100 [thread overview]
Message-ID: <1410773568-1573-7-git-send-email-swhiteho@redhat.com> (raw)
In-Reply-To: <1410773568-1573-1-git-send-email-swhiteho@redhat.com>
From: Al Viro <viro@ZenIV.linux.org.uk>
Callers of d_splice_alias(dentry, inode) don't need iput(), neither
on success nor on failure. Either the reference to inode is stored
in a previously negative dentry, or it's dropped. In either case
inode reference the caller used to hold is consumed.
__gfs2_lookup() does iput() in case when d_splice_alias() has failed.
Double iput() if we ever hit that. And gfs2_create_inode() ends up
not only with double iput(), but with link count dropped to zero - on
an inode it has just found in directory.
Cc: stable at vger.kernel.org # v3.14+
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 9317ddc..fc8ac2e 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -626,8 +626,10 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
if (!IS_ERR(inode)) {
d = d_splice_alias(inode, dentry);
error = PTR_ERR(d);
- if (IS_ERR(d))
+ if (IS_ERR(d)) {
+ inode = ERR_CAST(d);
goto fail_gunlock;
+ }
error = 0;
if (file) {
if (S_ISREG(inode->i_mode)) {
@@ -856,7 +858,6 @@ static struct dentry *__gfs2_lookup(struct inode *dir, struct dentry *dentry,
d = d_splice_alias(inode, dentry);
if (IS_ERR(d)) {
- iput(inode);
gfs2_glock_dq_uninit(&gh);
return d;
}
--
1.8.3.1
prev parent reply other threads:[~2014-09-15 9:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-15 9:32 [Cluster-devel] GFS2: Pre-pull patch posting (fixes) Steven Whitehouse
2014-09-15 9:32 ` [Cluster-devel] [PATCH 1/6] GFS2: fs/gfs2/super.c: replace seq_printf by seq_puts Steven Whitehouse
2014-09-15 9:32 ` [Cluster-devel] [PATCH 2/6] GFS2: Change maxlen variables to size_t Steven Whitehouse
2014-09-15 9:32 ` [Cluster-devel] [PATCH 3/6] GFS2: Request demote when a "try" flock fails Steven Whitehouse
2014-09-15 9:32 ` [Cluster-devel] [PATCH 4/6] GFS2: Hash the negative dentry during inode lookup Steven Whitehouse
2014-09-15 9:32 ` [Cluster-devel] [PATCH 5/6] GFS2: Don't use MAXQUOTAS value Steven Whitehouse
2014-09-15 9:32 ` Steven Whitehouse [this message]
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=1410773568-1573-7-git-send-email-swhiteho@redhat.com \
--to=swhiteho@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;
as well as URLs for NNTP newsgroup(s).