Edward O'Callaghan has uploaded this change for review.
flashrom.c: Replace 'exit(1)' leaks with return codes on err paths
Do not just exit in the middle of the process, rather return
a value back up to the caller to allow proper resource cleanup's
to occur.
Change-Id: Ie4186a40071e9a7296d601582ff15ad7df09c70a
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
---
M flashrom.c
1 file changed, 17 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/74/69474/1
diff --git a/flashrom.c b/flashrom.c
index d0a38c5..47e7723 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -317,7 +317,7 @@
opt = malloc(optlen + 1);
if (!opt) {
msg_gerr("Out of memory!\n");
- exit(1);
+ return NULL;
}
strncpy(opt, opt_pos, optlen);
opt[optlen] = '\0';
@@ -453,7 +453,7 @@
uint8_t *cmpbuf = malloc(len);
if (!cmpbuf) {
msg_gerr("Out of memory!\n");
- exit(1);
+ return -1;
}
memset(cmpbuf, erased_value, len);
ret = verify_range(flash, cmpbuf, start, len);
@@ -896,7 +896,7 @@
flash->chip = calloc(1, sizeof(*flash->chip));
if (!flash->chip) {
msg_gerr("Out of memory!\n");
- exit(1);
+ return -1;
}
*flash->chip = *chip;
flash->mst = mst;
To view, visit change 69474. To unsubscribe, or for help writing mail filters, visit settings.