From 7a3eec2b4d9dbb9533acfb271dbe91afa0727c8e Mon Sep 17 00:00:00 2001 From: Tomas Vanek Date: Tue, 18 Dec 2018 17:17:33 +0100 Subject: target algo: do not write reg_param if direction is PARAM_IN Without this change xxx_start_algorithm() writes all register parameters no matter of their direction. It usually results in writing of uninitialized reg_params[].value - possibly reported by valgrind. While on it fix the wrong parameter direction in kinetis_disable_wdog_algo(). This bug did not have any impact because of unconditional write of reg_params. Change-Id: Ia9c6a7b37f77d5eb6e5f5463012dddd50471742b Signed-off-by: Tomas Vanek Reviewed-on: http://openocd.zylin.com/4813 Tested-by: jenkins Reviewed-by: Antonio Borneo Reviewed-by: Matthias Welwarsky --- src/target/riscv/riscv.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/target/riscv/riscv.c') diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index 8d76c4aa..02ba3805 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -853,6 +853,9 @@ static int riscv_run_algorithm(struct target *target, int num_mem_params, uint64_t saved_regs[32]; for (int i = 0; i < num_reg_params; i++) { + if (mem_params[i].direction == PARAM_IN) + continue; + LOG_DEBUG("save %s", reg_params[i].reg_name); struct reg *r = register_get_by_name(target->reg_cache, reg_params[i].reg_name, 0); if (!r) { -- cgit v1.2.3-18-g5258