Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

Commit

Permalink
security: testing the wrong variable in create_by_name()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
error27 authored and James Morris committed Apr 22, 2010
1 parent e134d20 commit b338cc8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions security/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ static int create_by_name(const char *name, mode_t mode,

mutex_lock(&parent->d_inode->i_mutex);
*dentry = lookup_one_len(name, parent, strlen(name));
if (!IS_ERR(dentry)) {
if (!IS_ERR(*dentry)) {
if ((mode & S_IFMT) == S_IFDIR)
error = mkdir(parent->d_inode, *dentry, mode);
else
error = create(parent->d_inode, *dentry, mode);
} else
error = PTR_ERR(dentry);
error = PTR_ERR(*dentry);
mutex_unlock(&parent->d_inode->i_mutex);

return error;
Expand Down

0 comments on commit b338cc8

Please sign in to comment.