aboutsummaryrefslogtreecommitdiff
path: root/src/flash/nor/tcl.c
diff options
context:
space:
mode:
authorBohdan Tymkiv <bhdt@cypress.com>2018-05-03 22:50:58 +0300
committerTomas Vanek <vanekt@fbl.cz>2018-08-01 14:32:26 +0100
commitd92773b2057ef163cd062b2408b99bdc3404f905 (patch)
tree55eda4e7f20b515a11b6b95767a7919fda7b812f /src/flash/nor/tcl.c
parent64bb6244794075b254ce1f08e8d2b1f2818ced51 (diff)
downloadriscv-openocd-d92773b2057ef163cd062b2408b99bdc3404f905.zip
riscv-openocd-d92773b2057ef163cd062b2408b99bdc3404f905.tar.gz
riscv-openocd-d92773b2057ef163cd062b2408b99bdc3404f905.tar.bz2
flash/nor/tcl.c: fix flash bank bounds check in 'flash fill' command handler
Steps to reproduce ( STM32F103 'Blue Pill', 128KiB of flash ): > flash fillh 0x0801FFFE 00 1 wrote 2 bytes to 0x0801fffe in 0.019088s (0.102 KiB/s) > flash fillw 0x0801FFFE 00 1 Error: stm32f1x.cpu -- clearing lockup after double fault Error: error waiting for target flash write algorithm Error: error writing to flash at address 0x08000000 at offset 0x0001fffe Change-Id: I145092ec5e45bc586b3df48bf37c38c9226915c1 Signed-off-by: Bohdan Tymkiv <bhdt@cypress.com> Reviewed-on: http://openocd.zylin.com/4516 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Diffstat (limited to 'src/flash/nor/tcl.c')
-rw-r--r--src/flash/nor/tcl.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c
index b4f375f..95ca819 100644
--- a/src/flash/nor/tcl.c
+++ b/src/flash/nor/tcl.c
@@ -506,7 +506,7 @@ COMMAND_HANDLER(handle_flash_fill_command)
if (count == 0)
return ERROR_OK;
- if (address + count >= bank->base + bank->size) {
+ if (address + count * wordsize > bank->base + bank->size) {
LOG_ERROR("Cannot cross flash bank borders");
return ERROR_FAIL;
}