aboutsummaryrefslogtreecommitdiffstats
path: root/dummyflasher.c
diff options
context:
space:
mode:
authorAnastasia Klimchuk <aklm@chromium.org>2022-06-20 13:31:21 +1000
committerAnastasia Klimchuk <aklm@chromium.org>2022-06-24 00:14:57 +0000
commit6f610a83918b9b1fe9d58578d0d9a8e51a407d6e (patch)
treeb0e8736e9de4a6afb0572161c504e6463a92c1aa /dummyflasher.c
parent970f9481ae23fb11114aaf2f5b103bd0e6e8c5d9 (diff)
downloadflashrom-6f610a83918b9b1fe9d58578d0d9a8e51a407d6e.tar.gz
flashrom-6f610a83918b9b1fe9d58578d0d9a8e51a407d6e.tar.bz2
flashrom-6f610a83918b9b1fe9d58578d0d9a8e51a407d6e.zip
dummyflasher: Handle invalid value of freq parameter
0 is an invalid value for freq parameter and caused floating point exception. This patch checks that freq is not 0 during initialisation. Fixes: https://ticket.coreboot.org/issues/366 TEST=the following scenarios 1) error $ ./flashrom -p dummy:emulate=W25Q128FV,freq=0 -V <...> init_data: invalid value 0 for freq parameter Unhandled programmer parameters (possibly due to another failure): emulate=W25Q128FV, Error: Programmer initialization failed. 2) successful $ ./flashrom -p dummy:emulate=W25Q128FV,freq=10 -V Found Winbond flash chip "W25Q128.V" (16384 kB, SPI). 3) default is also successful $ ./flashrom -p dummy:emulate=W25Q128FV -V Found Winbond flash chip "W25Q128.V" (16384 kB, SPI). Change-Id: I0a95495de0a677f0d4d7f4c2fc61dcbc00d6ad4c Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/65240 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Felix Singer <felixsinger@posteo.net>
Diffstat (limited to 'dummyflasher.c')
-rw-r--r--dummyflasher.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/dummyflasher.c b/dummyflasher.c
index b56350e7..603e545e 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -1102,6 +1102,11 @@ static int init_data(struct emu_data *data, enum chipbustype *dummy_buses_suppor
}
}
+ if (freq == 0) {
+ msg_perr("%s: invalid value 0 for freq parameter\n", __func__);
+ free(tmp);
+ return 1;
+ }
/* Assume we only work with bytes and transfer at 1 bit/Hz */
data->delay_us = (1000000 * 8) / freq;
}