|
From: openocd-gerrit <ope...@us...> - 2025-11-12 20:34:52
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via be083909b709e05da7c2891bc0da59059e99f758 (commit)
from ed9cf6d81d9ea9300625a9a69281a2a93e3012fc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit be083909b709e05da7c2891bc0da59059e99f758
Author: Antonio Borneo <bor...@gm...>
Date: Tue Oct 7 12:06:54 2025 +0200
target: riscv: fix memory leak in riscv_openocd_step_impl()
The array 'wps_to_enable' is never freed.
Scan build reports:
src/target/riscv/riscv.c:4271:6: warning: Potential leak
of memory pointed to by 'wps_to_enable' [unix.Malloc]
Add the needed free().
While there, check if the allocation is successful.
Change-Id: I00e7ade37a43a97dcc245113ad93c48784fce609
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9163
Reviewed-by: Evgeniy Naydanov <evg...@sy...>
Reviewed-by: Tomas Vanek <va...@fb...>
Tested-by: jenkins
diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c
index 7ad695c20..9d858276b 100644
--- a/src/target/riscv/riscv.c
+++ b/src/target/riscv/riscv.c
@@ -4210,9 +4210,15 @@ static int riscv_openocd_step_impl(struct target *target, bool current,
RISCV_INFO(r);
bool *wps_to_enable = calloc(r->trigger_count, sizeof(*wps_to_enable));
+ if (!wps_to_enable) {
+ LOG_ERROR("Out of memory");
+ return ERROR_FAIL;
+ }
+
if (disable_watchpoints(target, wps_to_enable) != ERROR_OK) {
LOG_TARGET_ERROR(target, "Failed to temporarily disable "
"watchpoints before single-step.");
+ free(wps_to_enable);
return ERROR_FAIL;
}
@@ -4257,6 +4263,8 @@ _exit:
"after single-step.");
}
+ free(wps_to_enable);
+
if (breakpoint && (riscv_add_breakpoint(target, breakpoint) != ERROR_OK)) {
success = false;
LOG_TARGET_ERROR(target, "Unable to restore the disabled breakpoint.");
-----------------------------------------------------------------------
Summary of changes:
src/target/riscv/riscv.c | 8 ++++++++
1 file changed, 8 insertions(+)
hooks/post-receive
--
Main OpenOCD repository
|