Attention is currently required from: Patrick Georgi, Stefan Reinauer, Edward O'Callaghan, Angel Pons.

Nico Huber would like build bot (Jenkins), Patrick Georgi, Stefan Reinauer, Edward O'Callaghan and Angel Pons to review this change.

View Change

stlinkv3_spi: Avoid division by zero

Change-Id: I08c0612f3fea59add9bde2fb3cc5c4b5c3756516
Found-by: Coverity Scan #1412744
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/40653
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
---
M stlinkv3_spi.c
1 file changed, 19 insertions(+), 2 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/64/67864/1
diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c
index 7338911..d2988b6 100644
--- a/stlinkv3_spi.c
+++ b/stlinkv3_spi.c
@@ -491,10 +491,11 @@
speed_str = extract_programmer_param("spispeed");
if (speed_str) {
sck_freq_kHz = strtoul(speed_str, &endptr, 0);
- if (*endptr) {
+ if (*endptr || sck_freq_kHz == 0) {
msg_perr("The spispeed parameter passed with invalid format: %s\n",
speed_str);
- msg_perr("Please pass the parameter with a simple number in kHz\n");
+ msg_perr("Please pass the parameter "
+ "with a simple non-zero number in kHz\n");
return -1;
}
free(speed_str);

To view, visit change 67864. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: 1.2.x
Gerrit-Change-Id: I08c0612f3fea59add9bde2fb3cc5c4b5c3756516
Gerrit-Change-Number: 67864
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Patrick Georgi <patrick@coreboot.org>
Gerrit-Reviewer: Stefan Reinauer <stefan.reinauer@coreboot.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-Attention: Patrick Georgi <patrick@coreboot.org>
Gerrit-Attention: Stefan Reinauer <stefan.reinauer@coreboot.org>
Gerrit-Attention: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus@gmail.com>
Gerrit-MessageType: newchange