[Mesa-dev] [PATCH] r600g: Prevent by invalid op overflows in release builds.

Vinson Lee vlee at freedesktop.org
Fri Sep 27 23:37:12 PDT 2013


Fixes "Overflowed return value" defects reported by Coverity.

Signed-off-by: Vinson Lee <vlee at freedesktop.org>
---
 src/gallium/drivers/r600/r600_isa.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/gallium/drivers/r600/r600_isa.h b/src/gallium/drivers/r600/r600_isa.h
index c6bb869..5b9c3d0 100644
--- a/src/gallium/drivers/r600/r600_isa.h
+++ b/src/gallium/drivers/r600/r600_isa.h
@@ -1210,6 +1210,9 @@ r600_isa_alu_by_opcode(struct r600_isa* isa, unsigned opcode, unsigned is_op3) {
 		op = isa->alu_op2_map[opcode];
 	}
 	assert(op);
+	if (!op) {
+		return 0;
+	}
 	return op - 1;
 }
 
@@ -1219,6 +1222,9 @@ r600_isa_fetch_by_opcode(struct r600_isa* isa, unsigned opcode) {
 	assert(isa->fetch_map);
 	op = isa->fetch_map[opcode];
 	assert(op);
+	if (!op) {
+		return 0;
+	}
 	return op - 1;
 }
 
@@ -1230,6 +1236,9 @@ r600_isa_cf_by_opcode(struct r600_isa* isa, unsigned opcode, unsigned is_alu) {
 	 * CF opcodes (they use different encoding in hw) */
 	op = isa->cf_map[is_alu ? opcode + 0x80 : opcode];
 	assert(op);
+	if (!op) {
+		return 0;
+	}
 	return op - 1;
 }
 
-- 
1.8.3.1



More information about the mesa-dev mailing list