diff options
author | Edward O'Callaghan <quasisec@google.com> | 2022-11-12 12:08:01 +1100 |
---|---|---|
committer | Edward O'Callaghan <quasisec@chromium.org> | 2022-12-12 12:40:26 +0000 |
commit | d1212796abc68ff480ff862d1a09ec3a1942fe97 (patch) | |
tree | 4c1a879e62bc06d7dc4542bb68231aabba2697cd | |
parent | 1e01eefcba573c436d55b863c7972b3029564215 (diff) | |
download | flashrom-d1212796abc68ff480ff862d1a09ec3a1942fe97.tar.gz flashrom-d1212796abc68ff480ff862d1a09ec3a1942fe97.tar.bz2 flashrom-d1212796abc68ff480ff862d1a09ec3a1942fe97.zip |
flashrom.c: Position heap alloc along side check in compare_range()
Change-Id: I0386ac4c09a541cb9a659b2410ce49c3292ecc6e
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/69473
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Alexander Goncharov <chat@joursoir.net>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r-- | flashrom.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -471,15 +471,16 @@ static int compare_range(const uint8_t *wantbuf, const uint8_t *havebuf, unsigne static int check_erased_range(struct flashctx *flash, unsigned int start, unsigned int len) { int ret; - uint8_t *cmpbuf = malloc(len); const uint8_t erased_value = ERASED_VALUE(flash); + uint8_t *cmpbuf = malloc(len); if (!cmpbuf) { msg_gerr("Out of memory!\n"); return -1; } memset(cmpbuf, erased_value, len); ret = verify_range(flash, cmpbuf, start, len); + free(cmpbuf); return ret; } |