Skip to content

Commit

Permalink
securityfs: Drop dentry reference count when mknod fails
Browse files Browse the repository at this point in the history
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: Tvrtko Ursulin <[email protected]>
Acked-by: Serge E. Hallyn <[email protected]>
Acked-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
Tvrtko Ursulin authored and James Morris committed Aug 2, 2010
1 parent 57a62c2 commit b8bc83a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion security/inode.c
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit b8bc83a

Please sign in to comment.