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.

flashrom-stable:
* Dropped change to extract_param() because it can't return errors

Change-Id: Ie4186a40071e9a7296d601582ff15ad7df09c70a
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/69474
Original-Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72365
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/flashrom.c b/flashrom.c
index 820c628..e745aad 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -353,7 +353,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);
@@ -700,7 +700,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;