Angel Pons has uploaded this change for review.

View Change

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>
---
M dummyflasher.c
1 file changed, 6 insertions(+), 6 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/08/54908/1
diff --git a/dummyflasher.c b/dummyflasher.c
index 8955254..78f3837 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -967,12 +967,6 @@
}
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");
if (status) {
@@ -990,6 +984,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 0x%02x, size %i\n",
data->erase_to_zero ? 0x00 : 0xff, data->emu_chip_size);
memset(data->flashchip_contents, data->erase_to_zero ? 0x00 : 0xff, data->emu_chip_size);

To view, visit change 54908. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie907ac88dfe4ca018c97d9ce6ce042b4ffacf36a
Gerrit-Change-Number: 54908
Gerrit-PatchSet: 1
Gerrit-Owner: Angel Pons <th3fanbus@gmail.com>
Gerrit-MessageType: newchange