From patchwork Mon Mar 4 22:39:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 2214751 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 4CEC4DF2F2 for ; Mon, 4 Mar 2013 21:41:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932645Ab3CDVlB (ORCPT ); Mon, 4 Mar 2013 16:41:01 -0500 Received: from nat-pool-rdu.redhat.com ([66.187.233.202]:48856 "EHLO bp-05.lab.msp.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932552Ab3CDVkc (ORCPT ); Mon, 4 Mar 2013 16:40:32 -0500 Received: by bp-05.lab.msp.redhat.com (Postfix, from userid 0) id D99CE1E0AAF; Mon, 4 Mar 2013 16:40:07 -0600 (CST) From: Eric Sandeen To: linux-btrfs@vger.kernel.org Cc: Eric Sandeen Subject: [PATCH 05/14] btrfs-progs: free allocated metadump structure on restore failure Date: Mon, 4 Mar 2013 16:39:55 -0600 Message-Id: <1362436804-16766-6-git-send-email-sandeen@redhat.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1362436804-16766-1-git-send-email-sandeen@redhat.com> References: <1362436804-16766-1-git-send-email-sandeen@redhat.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Don't return w/ "metadump" still allocated Signed-off-by: Eric Sandeen --- btrfs-image.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/btrfs-image.c b/btrfs-image.c index a54e6c9..5b0af28 100644 --- a/btrfs-image.c +++ b/btrfs-image.c @@ -765,11 +765,11 @@ static int wait_for_worker(struct mdrestore_struct *mdres) static int restore_metadump(const char *input, FILE *out, int num_threads) { - struct meta_cluster *cluster; + struct meta_cluster *cluster = NULL; struct meta_cluster_header *header; struct mdrestore_struct mdrestore; u64 bytenr = 0; - FILE *in; + FILE *in = NULL; int ret; if (!strcmp(input, "-")) { @@ -797,14 +797,15 @@ static int restore_metadump(const char *input, FILE *out, int num_threads) if (le64_to_cpu(header->magic) != HEADER_MAGIC || le64_to_cpu(header->bytenr) != bytenr) { fprintf(stderr, "bad header in metadump image\n"); - return 1; + ret = 1; + goto out; } ret = add_cluster(cluster, &mdrestore, &bytenr); BUG_ON(ret); wait_for_worker(&mdrestore); } - +out: mdrestore_destroy(&mdrestore); free(cluster); if (in != stdin)