diff --git a/fs/namei.c b/fs/namei.c index 94b27370f468..c36ff6f8195a 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4367,11 +4367,9 @@ int do_unlinkat(int dfd, struct filename *name) if (!IS_ERR(dentry)) { /* Why not before? Because we want correct error value */ - if (last.name[last.len]) + if (last.name[last.len] || d_is_negative(dentry)) goto slashes; inode = dentry->d_inode; - if (d_is_negative(dentry)) - goto slashes; ihold(inode); error = security_path_unlink(&path, dentry); if (error)