Skip to content

Commit b338cc8

Browse files
error27xjamesmorris
authored andcommitted
security: testing the wrong variable in create_by_name()
There is a typo here. We should be testing "*dentry" instead of "dentry". If "*dentry" is an ERR_PTR, it gets dereferenced in either mkdir() or create() which would cause an OOPs. Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: James Morris <jmorris@namei.org>
1 parent e134d20 commit b338cc8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎security/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,13 @@ static int create_by_name(const char *name, mode_t mode,
161161

162162
mutex_lock(&parent->d_inode->i_mutex);
163163
*dentry = lookup_one_len(name, parent, strlen(name));
164-
if (!IS_ERR(dentry)) {
164+
if (!IS_ERR(*dentry)) {
165165
if ((mode & S_IFMT) == S_IFDIR)
166166
error = mkdir(parent->d_inode, *dentry, mode);
167167
else
168168
error = create(parent->d_inode, *dentry, mode);
169169
} else
170-
error = PTR_ERR(dentry);
170+
error = PTR_ERR(*dentry);
171171
mutex_unlock(&parent->d_inode->i_mutex);
172172

173173
return error;

0 commit comments

Comments
 (0)