diff --git a/fs/namei.c b/fs/namei.c index 5512cb10fa89..9e5214dfd05d 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4419,7 +4419,8 @@ int vfs_unlink(struct mnt_idmap *idmap, struct inode *dir, error = try_break_deleg(target, delegated_inode); if (error) goto out; - error = dir->i_op->unlink(dir, dentry); + if (dentry->d_inode->i_nlink) + error = dir->i_op->unlink(dir, dentry); if (!error) { dont_mount(dentry); detach_mounts(dentry);