From patchwork Sun Oct 27 06:04:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cong Ding X-Patchwork-Id: 3099211 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 693ED9F52D for ; Sun, 27 Oct 2013 06:05:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A3F8E2024A for ; Sun, 27 Oct 2013 06:05:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3238620259 for ; Sun, 27 Oct 2013 06:05:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751088Ab3J0GE3 (ORCPT ); Sun, 27 Oct 2013 02:04:29 -0400 Received: from mail-pb0-f53.google.com ([209.85.160.53]:49232 "EHLO mail-pb0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750938Ab3J0GE2 (ORCPT ); Sun, 27 Oct 2013 02:04:28 -0400 Received: by mail-pb0-f53.google.com with SMTP id up7so5064364pbc.26 for ; Sat, 26 Oct 2013 23:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=gyK1yFaEVOeCXDxShyehqWjB8d98TweelvAxcTPYwrw=; b=j4TnzGkVPXjvx1cWf8Z6l24+o1sVupfLC8qkgMWNoC2vlSujRvTYZyDSKNTacEHaJq IF8VyjhtfYmKM+8jqTddiVqoi2g/64e3lidIyg1/LbEF9Tre/l+3UGW/iIuGoIfTuLxv rK2JKTs01vSC+kkhEWAZxtjTA6IytD4nxKRi/AOrm2UAtRyTDyeZ69U698aQVD1bpxc7 oO9iv4upYDwMF7bcLEUXJT0eliWGyKPSPA6YHmfWs2hOhIiQWjNMYtvJvyUejz1lEk++ YtrPnrVwK/0HQhNGK788otNmbHlmqaacsQpgagE3TBujOkD0aZg8PKpAJVwrxvJial/i jjOg== X-Received: by 10.68.170.133 with SMTP id am5mr9787139pbc.104.1382853867723; Sat, 26 Oct 2013 23:04:27 -0700 (PDT) Received: from cd-ucr.cs.ucr.edu ([169.235.25.200]) by mx.google.com with ESMTPSA id xs1sm25343450pac.7.2013.10.26.23.04.26 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 26 Oct 2013 23:04:27 -0700 (PDT) From: Cong Ding To: Chris Mason , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Cong Ding Subject: [PATCH] btrfs: fix memory leakage Date: Sat, 26 Oct 2013 23:04:05 -0700 Message-Id: <1382853846-1900-1-git-send-email-dinggnu@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The memory allocated to "name" by function "extref_get_fields" isn't properly freed when error occurs. Signed-off-by: Cong Ding --- fs/btrfs/tree-log.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 79f057c..e75f3ed 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -1169,8 +1169,10 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans, */ if (!dir) dir = read_one_inode(root, parent_objectid); - if (!dir) + if (!dir) { + kfree(name); return -ENOENT; + } } else { ret = ref_get_fields(eb, ref_ptr, &namelen, &name, &ref_index);