ocfs2: Add missing iput() during error handling in ocfs2_dentry_attach_lock()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Saturday, May 2, 2009 - 5:00 pm

Gitweb:     http://git.kernel.org/linus/a5a0a630922a2f6a774b6dac19f70cb5abd86bb0
Commit:     a5a0a630922a2f6a774b6dac19f70cb5abd86bb0
Parent:     5b09b507daaa882d888b6cd78ee89ba9caace44b
Author:     Sunil Mushran <sunil.mushran@oracle.com>
AuthorDate: Mon Apr 20 21:34:18 2009 -0700
Committer:  Joel Becker <joel.becker@oracle.com>
CommitDate: Thu Apr 23 14:56:13 2009 -0700

    ocfs2: Add missing iput() during error handling in ocfs2_dentry_attach_lock()
    
    In ocfs2_dentry_attach_lock(), if unable to get the dentry lock, we need to
    call iput(inode) because a failure here means no d_instantiate(), which means
    the normally matching iput() will not be called during dput(dentry).
    
    This patch fixes the oops that accompanies the following message:
    (3996,1):dlm_empty_lockres:2708 ERROR: lockres W00000000000000000a1046b06a4382 still has local locks!
    kernel BUG in dlm_empty_lockres at /rpmbuild/smushran/BUILD/ocfs2-1.4.2/fs/ocfs2/dlm/dlmmaster.c:2709!
    
    Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
    Signed-off-by: Joel Becker <joel.becker@oracle.com>
---
 fs/ocfs2/dcache.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c
index 7d60448..b574431 100644
--- a/fs/ocfs2/dcache.c
+++ b/fs/ocfs2/dcache.c
@@ -290,6 +290,21 @@ out_attach:
 	else
 		mlog_errno(ret);
 
+	/*
+	 * In case of error, manually free the allocation and do the iput().
+	 * We need to do this because error here means no d_instantiate(),
+	 * which means iput() will not be called during dput(dentry).
+	 */
+	if (ret < 0 && !alias) {
+		ocfs2_lock_res_free(&dl->dl_lockres);
+		BUG_ON(dl->dl_count != 1);
+		spin_lock(&dentry_attach_lock);
+		dentry->d_fsdata = NULL;
+		spin_unlock(&dentry_attach_lock);
+		kfree(dl);
+		iput(inode);
+	}
+
 	dput(alias);
 
 	return ret;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
ocfs2: Add missing iput() during error handling in ocfs2_d ..., Linux Kernel Mailing ..., (Sat May 2, 5:00 pm)