diff --git a/daemon/btrfs.c b/daemon/btrfs.c index 26757d4fb..5c4be6cf7 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -1683,12 +1683,6 @@ do_btrfs_balance_status (const char *path) nlines = guestfs_int_count_strings (lines); - ret = calloc (1, sizeof *ret); - if (ret == NULL) { - reply_with_perror ("calloc"); - return NULL; - } - /* Output of `btrfs balance status' is like: * * running: @@ -1711,6 +1705,12 @@ do_btrfs_balance_status (const char *path) return NULL; } + ret = calloc (1, sizeof *ret); + if (ret == NULL) { + reply_with_perror ("calloc"); + return NULL; + } + if (strstr (lines[0], "No balance found on")) { ret->btrfsbalance_status = strdup ("none"); if (ret->btrfsbalance_status == NULL) {