From 01151f045ff44fe8e824c0bb903c7efcbc17d2d9 Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Thu, 13 Mar 2025 10:56:39 +0100 Subject: [PATCH] broadcom/compiler: use safe iterator to remove instructions The current approach has an issue detected by static analyzer: use of memory after it is freed. Using a proper iterator makes things safer. Signed-off-by: Juan A. Suarez Romero Reviewed-by: Jose Maria Casanova Crespo Reviewed-by: Iago Toral Quiroga Part-of: --- src/broadcom/compiler/vir.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c index 687062bf765..ee9824b4fc1 100644 --- a/src/broadcom/compiler/vir.c +++ b/src/broadcom/compiler/vir.c @@ -2197,10 +2197,7 @@ vir_compile_destroy(struct v3d_compile *c) c->cursor.link = NULL; vir_for_each_block(block, c) { - while (!list_is_empty(&block->instructions)) { - struct qinst *qinst = - list_first_entry(&block->instructions, - struct qinst, link); + list_for_each_entry_safe(struct qinst, qinst, &block->instructions, link) { vir_remove_instruction(c, qinst); } }