From 0b0d6a36f22850922c91999bf282e7ec5c7635a9 Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Wed, 12 Mar 2025 17:15:17 +0100 Subject: [PATCH] vc4: 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/gallium/drivers/vc4/vc4_qir.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c index a680c6b28dc..d70dedf29e2 100644 --- a/src/gallium/drivers/vc4/vc4_qir.c +++ b/src/gallium/drivers/vc4/vc4_qir.c @@ -738,10 +738,7 @@ void qir_compile_destroy(struct vc4_compile *c) { qir_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) { qir_remove_instruction(c, qinst); } }