From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sage Weil Subject: [PATCH 01/18] vfs: dentry_unhash immediately prior to rmdir Date: Mon, 9 May 2011 21:43:19 -0700 Message-ID: <1305002616-16782-2-git-send-email-sage@newdream.net> References: <1305002616-16782-1-git-send-email-sage@newdream.net> Cc: Sage Weil To: viro@ZenIV.linux.org.uk, hch@lst.de, linux-fsdevel@vger.kernel.org Return-path: Received: from cobra.newdream.net ([66.33.216.30]:57263 "EHLO cobra.newdream.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751581Ab1EJFKh (ORCPT ); Tue, 10 May 2011 01:10:37 -0400 In-Reply-To: <1305002616-16782-1-git-send-email-sage@newdream.net> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: This presumes that there is no reason to unhash a dentry if we fail because it is a mountpoint or the LSM check fails, and that the LSM checks do not depend on the dentry being unhashed. Signed-off-by: Sage Weil --- fs/namei.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 54fc993..d71c035 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2664,24 +2664,24 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry) return -EPERM; mutex_lock(&dentry->d_inode->i_mutex); - dentry_unhash(dentry); if (d_mountpoint(dentry)) error = -EBUSY; else { error = security_inode_rmdir(dir, dentry); if (!error) { + dentry_unhash(dentry); error = dir->i_op->rmdir(dir, dentry); if (!error) { dentry->d_inode->i_flags |= S_DEAD; dont_mount(dentry); } + dput(dentry); } } mutex_unlock(&dentry->d_inode->i_mutex); if (!error) { d_delete(dentry); } - dput(dentry); return error; } -- 1.7.1