提交 16370235 编写于 作者: H Hyunchul Lee 提交者: Steve French

cifsd: handle unhashed dentry in ksmbd_vfs_mkdir

vfs_mkdir could return the dentry left unhashed negative on success.
Signed-off-by: NHyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: NNamjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: NSteve French <stfrench@microsoft.com>
上级 96a34377
......@@ -190,14 +190,32 @@ int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode)
mode |= S_IFDIR;
err = vfs_mkdir(&init_user_ns, d_inode(path.dentry), dentry, mode);
if (!err) {
if (err)
goto out;
else if (d_unhashed(dentry)) {
struct dentry *d;
d = lookup_one_len(dentry->d_name.name,
dentry->d_parent,
dentry->d_name.len);
if (IS_ERR(d)) {
err = PTR_ERR(d);
goto out;
}
if (unlikely(d_is_negative(d))) {
dput(d);
err = -ENOENT;
goto out;
}
ksmbd_vfs_inherit_owner(work, d_inode(path.dentry),
d_inode(dentry));
} else {
ksmbd_err("mkdir(%s): creation failed (err:%d)\n", name, err);
d_inode(d));
dput(d);
}
out:
done_path_create(&path, dentry);
if (err)
ksmbd_err("mkdir(%s): creation failed (err:%d)\n", name, err);
return err;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册