From 8c410704154c28ca4354d85233ed76a29a031322 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Tue, 7 Oct 2025 12:14:15 +0200 Subject: [PATCH] target: riscv: fix double free() in parse_reg_ranges() The buffer 'args' is allocated and freed in the caller function parse_reg_ranges(). There is no reason to free it, only in some special case, in the called function parse_reg_ranges_impl(). Scan build reports: src/target/riscv/riscv.c:4537:2: warning: Attempt to free released memory [unix.Malloc] Drop the free() in the called function. Change-Id: I2e308670c502f8e140603b4e5c16fc568088e1a8 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/9164 Reviewed-by: Evgeniy Naydanov Tested-by: jenkins Reviewed-by: Tomas Vanek --- src/target/riscv/riscv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index 9d858276b..07aa578a5 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -4473,7 +4473,6 @@ static int parse_reg_ranges_impl(struct list_head *ranges, char *args, } } else { LOG_ERROR("Invalid argument '%s'.", arg); - free(args); return ERROR_COMMAND_SYNTAX_ERROR; }