Skip to content

Commit

Permalink
Btrfs: free inode struct when btrfs_new_inode fails
Browse files Browse the repository at this point in the history
btrfs_new_inode doesn't call iput to free the inode
when it fails.

Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Shen Feng authored and Chris Mason committed Apr 2, 2009
1 parent b5555f7 commit 0977143
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3481,8 +3481,10 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,

if (dir) {
ret = btrfs_set_inode_index(dir, index);
if (ret)
if (ret) {
iput(inode);
return ERR_PTR(ret);
}
}
/*
* index_cnt is ignored for everything but a dir,
Expand Down Expand Up @@ -3565,6 +3567,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
if (dir)
BTRFS_I(dir)->index_cnt--;
btrfs_free_path(path);
iput(inode);
return ERR_PTR(ret);
}

Expand Down

0 comments on commit 0977143

Please sign in to comment.