dummyflasher.c: Move `flashchip_contents` allocation

Place `flashchip_contents` allocation next to the code that initialises
the newly-allocated buffer. This also avoids leaking it if the handling
of `spi_status` fails.

Change-Id: Ie907ac88dfe4ca018c97d9ce6ce042b4ffacf36a
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/54908
Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Original-Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/71362
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/dummyflasher.c b/dummyflasher.c
index 4ed5301..3a78595 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -367,11 +367,6 @@
 		return 1;
 	}
 	free(tmp);
-	data->flashchip_contents = malloc(data->emu_chip_size);
-	if (!data->flashchip_contents) {
-		msg_perr("Out of memory!\n");
-		return 1;
-	}
 
 #ifdef EMULATE_SPI_CHIP
 	status = extract_programmer_param("spi_status");
@@ -389,6 +384,12 @@
 	}
 #endif
 
+	data->flashchip_contents = malloc(data->emu_chip_size);
+	if (!data->flashchip_contents) {
+		msg_perr("Out of memory!\n");
+		return 1;
+	}
+
 	msg_pdbg("Filling fake flash chip with 0xff, size %i\n", data->emu_chip_size);
 	memset(data->flashchip_contents, 0xff, data->emu_chip_size);