From patchwork Fri Feb 28 17:27:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Pandit X-Patchwork-Id: 3742981 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 111729F35F for ; Fri, 28 Feb 2014 17:27:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3FA2B202B4 for ; Fri, 28 Feb 2014 17:27:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0C129202DD for ; Fri, 28 Feb 2014 17:27:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753132AbaB1R1M (ORCPT ); Fri, 28 Feb 2014 12:27:12 -0500 Received: from nbl-ex10-fe01.nebula.fi ([188.117.32.121]:13485 "EHLO ex10.nebula.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752684AbaB1R1K (ORCPT ); Fri, 28 Feb 2014 12:27:10 -0500 Received: from localhost.localdomain (88.192.22.205) by ex10.nebula.fi (188.117.32.115) with Microsoft SMTP Server (TLS) id 14.3.174.1; Fri, 28 Feb 2014 19:28:13 +0200 Date: Fri, 28 Feb 2014 19:27:06 +0200 From: Rakesh Pandit To: Subject: [PATCH] Btrfs-progs: free path if we don't find root item Message-ID: <20140228172705.GA3536@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Originating-IP: [88.192.22.205] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 In btrfs_find_last_root before returning with -ENOENT (if root item is not found) free path and also remove btrfs_release_path before btrfs_free_path because btrfs_free_path anyway calls it. Signed-off-by: Rakesh Pandit --- root-tree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/root-tree.c b/root-tree.c index 858fe2f..f16f0ba 100644 --- a/root-tree.c +++ b/root-tree.c @@ -40,8 +40,10 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0); if (ret < 0) goto out; - if (path->slots[0] == 0) + if (path->slots[0] == 0) { + btrfs_free_path(path); return -ENOENT; + } BUG_ON(ret == 0); l = path->nodes[0]; @@ -56,7 +58,6 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, memcpy(key, &found_key, sizeof(found_key)); ret = 0; out: - btrfs_release_path(path); btrfs_free_path(path); return ret; } @@ -120,7 +121,6 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root write_extent_buffer(l, item, ptr, sizeof(*item)); btrfs_mark_buffer_dirty(path->nodes[0]); out: - btrfs_release_path(path); btrfs_free_path(path); return ret; }