diff options
author | Patrick Georgi <pgeorgi@google.com> | 2020-04-23 09:36:12 +0200 |
---|---|---|
committer | Angel Pons <th3fanbus@gmail.com> | 2020-04-24 08:22:52 +0000 |
commit | 552e60e5716277351ad8b6ca8a0652d0eeb8d986 (patch) | |
tree | e0c3c552372733c0585fdbff7d8c32a861829c74 | |
parent | 969e1ddff74149cd89ddb9a22021f28544ba8c96 (diff) | |
download | flashrom-552e60e5716277351ad8b6ca8a0652d0eeb8d986.tar.gz flashrom-552e60e5716277351ad8b6ca8a0652d0eeb8d986.tar.bz2 flashrom-552e60e5716277351ad8b6ca8a0652d0eeb8d986.zip |
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>
-rw-r--r-- | stlinkv3_spi.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c index 9e621c27..114c0cab 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -491,10 +491,11 @@ int stlinkv3_spi_init(void) 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"); free(speed_str); return -1; } |