Felix Singer submitted this change.

View Change



1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Approvals: build bot (Jenkins): Verified Felix Singer: Looks good to me, approved
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>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/69474
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M flashrom.c
1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/flashrom.c b/flashrom.c
index fde6d5a..9c22eb6 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -319,7 +319,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';
@@ -455,7 +455,7 @@

if (!cmpbuf) {
msg_gerr("Out of memory!\n");
- exit(1);
+ return -1;
}
memset(cmpbuf, erased_value, len);
ret = verify_range(flash, cmpbuf, start, len);
@@ -897,7 +897,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.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie4186a40071e9a7296d601582ff15ad7df09c70a
Gerrit-Change-Number: 69474
Gerrit-PatchSet: 3
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Felix Singer <felixsinger@posteo.net>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged