From patchwork Tue Aug 24 14:39:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 126741 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7OEdrSx009949 for ; Tue, 24 Aug 2010 14:39:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754811Ab0HXOjR (ORCPT ); Tue, 24 Aug 2010 10:39:17 -0400 Received: from mgw2.diku.dk ([130.225.96.92]:59392 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753003Ab0HXOjP (ORCPT ); Tue, 24 Aug 2010 10:39:15 -0400 Received: from localhost (localhost [127.0.0.1]) by mgw2.diku.dk (Postfix) with ESMTP id 73C8619BF22; Tue, 24 Aug 2010 16:39:14 +0200 (CEST) Received: from mgw2.diku.dk ([127.0.0.1]) by localhost (mgw2.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 04410-20; Tue, 24 Aug 2010 16:39:13 +0200 (CEST) Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140]) by mgw2.diku.dk (Postfix) with ESMTP id F1BEC19BEF2; Tue, 24 Aug 2010 16:39:12 +0200 (CEST) Received: from ask.diku.dk (ask.diku.dk [130.225.96.225]) by nhugin.diku.dk (Postfix) with ESMTP id C4E8E6DFD13; Tue, 24 Aug 2010 16:37:33 +0200 (CEST) Received: by ask.diku.dk (Postfix, from userid 3767) id D72F52015C; Tue, 24 Aug 2010 16:39:12 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by ask.diku.dk (Postfix) with ESMTP id D054B20159; Tue, 24 Aug 2010 16:39:12 +0200 (CEST) Date: Tue, 24 Aug 2010 16:39:12 +0200 (CEST) From: Julia Lawall To: Chris Mason , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 3/5] fs/btrfs: Eliminate memory leak Message-ID: MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 24 Aug 2010 14:39:54 +0000 (UTC) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index c038644..d38587c 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4438,15 +4438,14 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, BUG_ON(!path); inode = new_inode(root->fs_info->sb); - if (!inode) - return ERR_PTR(-ENOMEM); - + if (!inode) { + ret = -ENOMEM; + goto fail_path; + } if (dir) { ret = btrfs_set_inode_index(dir, index); - if (ret) { - iput(inode); - return ERR_PTR(ret); - } + if (ret) + goto fail_inode; } /* * index_cnt is ignored for everything but a dir, @@ -4519,8 +4518,10 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, fail: if (dir) BTRFS_I(dir)->index_cnt--; - btrfs_free_path(path); +fail_inode: iput(inode); +fail_path: + btrfs_free_path(path); return ERR_PTR(ret); }