stm32mon: terminate gracefully when failing to get commands list

When the CMD_GETCMD transaction fails, terminate immediately rather than
continuing and crashing when we use later the uninitialized 'erase'
function.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=b:77825616
TEST=flash Scarlet EC through CCD.

Change-Id: Ia40107fe27d81fdb9ee8220f73f4215d936a41c1
Reviewed-on: https://chromium-review.googlesource.com/1006595
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
This commit is contained in:
Vincent Palatin
2018-04-11 09:09:46 +02:00
committed by chrome-bot
parent 5b521e3ac6
commit ce02b59656

View File

@@ -525,6 +525,7 @@ int command_get_commands(int fd, struct stm32_def *chip)
return 0;
}
fprintf(stderr, "Cannot get bootloader command list.\n");
return -1;
}
@@ -1060,7 +1061,8 @@ int main(int argc, char **argv)
if (!chip)
goto terminate;
command_get_commands(ser, chip);
if (command_get_commands(ser, chip) < 0)
goto terminate;
if (flags & FLAG_READ_UNPROTECT)
command_read_unprotect(ser);