Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b338cc82 authored by Dan Carpenter's avatar Dan Carpenter Committed by James Morris
Browse files

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: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent e134d200
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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;