Skip to content

Commit 4829369

Browse files
liewegasAl Viro
authored andcommitted
vfs: dentry_unhash immediately prior to rmdir
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 <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent ea13a86 commit 4829369

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/namei.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,24 +2564,24 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
25642564
return -EPERM;
25652565

25662566
mutex_lock(&dentry->d_inode->i_mutex);
2567-
dentry_unhash(dentry);
25682567
if (d_mountpoint(dentry))
25692568
error = -EBUSY;
25702569
else {
25712570
error = security_inode_rmdir(dir, dentry);
25722571
if (!error) {
2572+
dentry_unhash(dentry);
25732573
error = dir->i_op->rmdir(dir, dentry);
25742574
if (!error) {
25752575
dentry->d_inode->i_flags |= S_DEAD;
25762576
dont_mount(dentry);
25772577
}
2578+
dput(dentry);
25782579
}
25792580
}
25802581
mutex_unlock(&dentry->d_inode->i_mutex);
25812582
if (!error) {
25822583
d_delete(dentry);
25832584
}
2584-
dput(dentry);
25852585

25862586
return error;
25872587
}

0 commit comments

Comments
 (0)