mirror of
https://github.com/kdave/btrfs-progs
synced 2025-05-04 17:07:55 +00:00
btrfs-progs: free allocated metadump structure on restore failure
Don't return w/ "metadump" still allocated Signed-off-by: Eric Sandeen <sandeen@redhat.com>
This commit is contained in:
parent
c74beb90ea
commit
dd53ec1c12
@ -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)
|
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 meta_cluster_header *header;
|
||||||
struct mdrestore_struct mdrestore;
|
struct mdrestore_struct mdrestore;
|
||||||
u64 bytenr = 0;
|
u64 bytenr = 0;
|
||||||
FILE *in;
|
FILE *in = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!strcmp(input, "-")) {
|
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 ||
|
if (le64_to_cpu(header->magic) != HEADER_MAGIC ||
|
||||||
le64_to_cpu(header->bytenr) != bytenr) {
|
le64_to_cpu(header->bytenr) != bytenr) {
|
||||||
fprintf(stderr, "bad header in metadump image\n");
|
fprintf(stderr, "bad header in metadump image\n");
|
||||||
return 1;
|
ret = 1;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
ret = add_cluster(cluster, &mdrestore, &bytenr);
|
ret = add_cluster(cluster, &mdrestore, &bytenr);
|
||||||
BUG_ON(ret);
|
BUG_ON(ret);
|
||||||
|
|
||||||
wait_for_worker(&mdrestore);
|
wait_for_worker(&mdrestore);
|
||||||
}
|
}
|
||||||
|
out:
|
||||||
mdrestore_destroy(&mdrestore);
|
mdrestore_destroy(&mdrestore);
|
||||||
free(cluster);
|
free(cluster);
|
||||||
if (in != stdin)
|
if (in != stdin)
|
||||||
|
Loading…
Reference in New Issue
Block a user