|
From: openocd-gerrit <ope...@us...> - 2025-04-19 09:21:21
|
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 cfed1f78db635b504e4d11da537e614adfd57d3f (commit)
from 16c5c1b353b06602d81a8a81f5243154a6c366cc (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 cfed1f78db635b504e4d11da537e614adfd57d3f
Author: Antonio Borneo <bor...@gm...>
Date: Sat Apr 5 17:04:43 2025 +0200
list: silent scan-build false positive
With commit c023534e7b6f ("target: use list for target events")
scan build incorrectly states that list_add() would be called with
the field 'next' of the parameter 'head' (thus 'head->next') set
to NULL. Then, list_add() would call linux_list_add() with the
parameter 'next' set to NULL that will cause a NULL dereference.
While this can really happen with broken code, it's not the case
with the code from the change above.
Add assert() in linux_list_add() to silent scan build on this
false positive and to detect future incorrect use of the list.
Change-Id: Iec7f3d70237312b646ac58f76ecaab2fa25eab41
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8824
Tested-by: jenkins
diff --git a/src/helper/list.h b/src/helper/list.h
index ba07f1556..89b8468ec 100644
--- a/src/helper/list.h
+++ b/src/helper/list.h
@@ -35,6 +35,7 @@
/* begin OpenOCD changes */
+#include <assert.h>
#include <stddef.h>
struct list_head {
@@ -109,6 +110,9 @@ static inline void
linux_list_add(struct list_head *new, struct list_head *prev,
struct list_head *next)
{
+ assert(next);
+ assert(prev);
+
next->prev = new;
new->next = next;
new->prev = prev;
-----------------------------------------------------------------------
Summary of changes:
src/helper/list.h | 4 ++++
1 file changed, 4 insertions(+)
hooks/post-receive
--
Main OpenOCD repository
|