mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-01 22:21:16 +02:00
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> Reviewed-on: https://review.coreboot.org/c/flashrom/+/54908 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:

committed by
Edward O'Callaghan

parent
6b1f3b0841
commit
2ef2efa0fa
@ -957,12 +957,6 @@ int dummy_init(void)
|
|||||||
}
|
}
|
||||||
free(tmp);
|
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
|
#ifdef EMULATE_SPI_CHIP
|
||||||
status = extract_programmer_param("spi_status");
|
status = extract_programmer_param("spi_status");
|
||||||
if (status) {
|
if (status) {
|
||||||
@ -979,6 +973,12 @@ int dummy_init(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#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",
|
msg_pdbg("Filling fake flash chip with 0x%02x, size %i\n",
|
||||||
data->erase_to_zero ? 0x00 : 0xff, data->emu_chip_size);
|
data->erase_to_zero ? 0x00 : 0xff, data->emu_chip_size);
|
||||||
memset(data->flashchip_contents, data->erase_to_zero ? 0x00 : 0xff, data->emu_chip_size);
|
memset(data->flashchip_contents, data->erase_to_zero ? 0x00 : 0xff, data->emu_chip_size);
|
||||||
|
Reference in New Issue
Block a user