Btrfs: fix memory leaks in btrfs_new_inode()
authorYoshinori Sano <yoshinori.sano@gmail.com>
Sat, 9 Apr 2011 02:30:07 +0000 (02:30 +0000)
committerChris Mason <chris.mason@oracle.com>
Tue, 12 Apr 2011 00:25:06 +0000 (20:25 -0400)
This patch fixes memory leaks in btrfs_new_inode().

Signed-off-by: Yoshinori Sano <yoshinori.sano@gmail.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/inode.c

index cc6022842e0c490911782d8122f1b052a5d5808f..2d1208f964eb0aec8ef143d64f7bcbc896ee29d7 100644 (file)
@@ -4526,14 +4526,17 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
        BUG_ON(!path);
 
        inode = new_inode(root->fs_info->sb);
-       if (!inode)
+       if (!inode) {
+               btrfs_free_path(path);
                return ERR_PTR(-ENOMEM);
+       }
 
        if (dir) {
                trace_btrfs_inode_request(dir);
 
                ret = btrfs_set_inode_index(dir, index);
                if (ret) {
+                       btrfs_free_path(path);
                        iput(inode);
                        return ERR_PTR(ret);
                }