From patchwork Thu Sep 5 02:38:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Hecheng X-Patchwork-Id: 2853879 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2F465C0AB5 for ; Thu, 5 Sep 2013 02:40:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2B35F20145 for ; Thu, 5 Sep 2013 02:40:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0DFFF20131 for ; Thu, 5 Sep 2013 02:40:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762110Ab3IECkm (ORCPT ); Wed, 4 Sep 2013 22:40:42 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:62090 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1758867Ab3IECki (ORCPT ); Wed, 4 Sep 2013 22:40:38 -0400 X-IronPort-AV: E=Sophos;i="4.90,843,1371052800"; d="scan'208";a="8417101" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 05 Sep 2013 10:37:28 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r852eZQ4014035 for ; Thu, 5 Sep 2013 10:40:35 +0800 Received: from localhost.localdomain ([10.167.226.111]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013090510382630-1242565 ; Thu, 5 Sep 2013 10:38:26 +0800 From: Gui Hecheng To: linux-btrfs@vger.kernel.org Cc: Gui Hecheng Subject: [PATCH 3/5] btrfs-progs: missing tree-freeing statements added Date: Thu, 5 Sep 2013 10:38:56 +0800 Message-Id: <1378348738-14451-4-git-send-email-guihc.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.0.1 In-Reply-To: <1378348738-14451-1-git-send-email-guihc.fnst@cn.fujitsu.com> References: <1378348738-14451-1-git-send-email-guihc.fnst@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/09/05 10:38:26, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/09/05 10:38:26, Serialize complete at 2013/09/05 10:38:26 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 seen cache_tree in run_next_block freed. Originally, this "missing" causes memory leaks, reported by valgrind. Signed-off-by: Gui Hecheng --- cmds-check.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmds-check.c b/cmds-check.c index 6cbd5a6..0cba4cc 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -3595,6 +3595,11 @@ static int run_next_block(struct btrfs_root *root, remove_cache_extent(nodes, cache); free(cache); } + cache = lookup_cache_extent(seen, bytenr, size); + if (cache) { + remove_cache_extent(seen, cache); + free(cache); + } /* fixme, get the real parent transid */ buf = read_tree_block(root, bytenr, size, 0);