summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2013-03-04 16:39:55 -0600
committerDavid Sterba <dsterba@suse.cz>2013-03-10 15:49:15 +0100
commitdd53ec1c12e0794fed80bc9596d9da7823a61714 (patch)
treee0342c2337a0b60f8de83af0ad3082b0177f9179
parentc74beb90eaf2ddedfcabc35cf81bac580f5aa9b6 (diff)
btrfs-progs: free allocated metadump structure on restore failure
Don't return w/ "metadump" still allocated Signed-off-by: Eric Sandeen <sandeen@redhat.com>
-rw-r--r--btrfs-image.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/btrfs-image.c b/btrfs-image.c
index a54e6c9d..5b0af283 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)