From patchwork Sun Sep 22 12:31:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Rajendra X-Patchwork-Id: 2924311 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 177C69F524 for ; Sun, 22 Sep 2013 12:31:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4BF57204A3 for ; Sun, 22 Sep 2013 12:31:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 39682202BE for ; Sun, 22 Sep 2013 12:31:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752900Ab3IVMbk (ORCPT ); Sun, 22 Sep 2013 08:31:40 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:43843 "EHLO e23smtp06.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752349Ab3IVMbj (ORCPT ); Sun, 22 Sep 2013 08:31:39 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 22 Sep 2013 22:31:37 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 22 Sep 2013 22:31:36 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id D363F2CE8051 for ; Sun, 22 Sep 2013 22:31:35 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r8MCExa766846924 for ; Sun, 22 Sep 2013 22:14:59 +1000 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r8MCVYLD023844 for ; Sun, 22 Sep 2013 22:31:35 +1000 Received: from localhost.localdomain ([9.79.209.104]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r8MCVVB4023777 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 22 Sep 2013 22:31:34 +1000 From: chandan To: linux-btrfs@vger.kernel.org Cc: sekharan@us.ibm.com Subject: [PATCH] btrfs-progs: verify_space_cache: Fix memory leak. Date: Sun, 22 Sep 2013 18:01:31 +0530 Message-ID: <12213854.o0zn9z9jeG@localhost.localdomain> User-Agent: KMail/4.10.5 (Linux/3.10.11-200.fc19.x86_64; KDE/4.10.5; x86_64; ; ) MIME-Version: 1.0 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13092212-7014-0000-0000-000003A69178 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.2 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 Free btrfs_path structure before returning due to failure of calls to btrfs_search_slot() or btrfs_next_leaf() functions. Signed-off-by: chandan --- cmds-check.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index e08b79d..c947156 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -3227,14 +3227,19 @@ static int verify_space_cache(struct btrfs_root *root, key.type = BTRFS_EXTENT_ITEM_KEY; ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); - if (ret < 0) + if (ret < 0) { + btrfs_free_path(path); return ret; + } + ret = 0; while (1) { if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) { ret = btrfs_next_leaf(root, path); - if (ret < 0) + if (ret < 0) { + btrfs_free_path(path); return ret; + } if (ret > 0) { ret = 0; break;