Mesa (master): freedreno: Fix invalid read when a block has no instructions.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Sep 16 22:21:15 UTC 2019


Module: Mesa
Branch: master
Commit: eea6f21cbdcd758a7a071485b854723ce32d1641
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=eea6f21cbdcd758a7a071485b854723ce32d1641

Author: Eric Anholt <eric at anholt.net>
Date:   Tue Sep  3 14:19:36 2019 -0700

freedreno: Fix invalid read when a block has no instructions.

We can't deref list_(first/last)_entries unless we know we have at least
one.  Instead, just use our IP we've been tracking as we go to set up the
start ip, and fill in the end IP as we walk instructions.

Fixes a complaint in valgrind on
dEQP-GLES3.functional.transform_feedback.* which sometimes has an
empty main (non-END) block when the VS inputs are just directly mapped
to outputs without any ALU ops.

Reviewed-by: Rob Clark <robdclark at chromium.org>

---

 src/freedreno/ir3/ir3.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/freedreno/ir3/ir3.c b/src/freedreno/ir3/ir3.c
index feec723abd0..68e83f7495e 100644
--- a/src/freedreno/ir3/ir3.c
+++ b/src/freedreno/ir3/ir3.c
@@ -1071,11 +1071,12 @@ ir3_count_instructions(struct ir3 *ir)
 {
 	unsigned cnt = 0;
 	list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+		block->start_ip = cnt;
+		block->end_ip = cnt;
 		list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
 			instr->ip = cnt++;
+			block->end_ip = instr->ip;
 		}
-		block->start_ip = list_first_entry(&block->instr_list, struct ir3_instruction, node)->ip;
-		block->end_ip = list_last_entry(&block->instr_list, struct ir3_instruction, node)->ip;
 	}
 	return cnt;
 }




More information about the mesa-commit mailing list