提交 b8bc83ab 编写于 作者: T Tvrtko Ursulin 提交者: James Morris

securityfs: Drop dentry reference count when mknod fails

lookup_one_len increments dentry reference count which is not decremented
when the create operation fails. This can cause a kernel BUG at
fs/dcache.c:676 at unmount time. Also error code returned when new_inode()
fails was replaced with more appropriate -ENOMEM.
Signed-off-by: NTvrtko Ursulin <tvrtko.ursulin@sophos.com>
Acked-by: NSerge E. Hallyn <serge@hallyn.com>
Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: NJames Morris <jmorris@namei.org>
上级 57a62c23
......@@ -86,7 +86,7 @@ static int mknod(struct inode *dir, struct dentry *dentry,
int mode, dev_t dev)
{
struct inode *inode;
int error = -EPERM;
int error = -ENOMEM;
if (dentry->d_inode)
return -EEXIST;
......@@ -166,6 +166,8 @@ static int create_by_name(const char *name, mode_t mode,
error = mkdir(parent->d_inode, *dentry, mode);
else
error = create(parent->d_inode, *dentry, mode);
if (error)
dput(*dentry);
} else
error = PTR_ERR(*dentry);
mutex_unlock(&parent->d_inode->i_mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册