From 2c8411e9d2c6d69cafc3a41128f5eb119289f1eb Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Fri, 10 Jan 2025 14:12:45 +0100 Subject: [PATCH] vc4: check instruction before setting flags This fixes an issue detected by static analyzer: access to field 'sf' results in a dereference of a null pointer (loaded from variable 'last_inst'). 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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c index 7cfe685f1a3..a680c6b28dc 100644 --- a/src/gallium/drivers/vc4/vc4_qir.c +++ b/src/gallium/drivers/vc4/vc4_qir.c @@ -809,7 +809,9 @@ qir_SF(struct vc4_compile *c, struct qreg src) last_inst != c->defs[src.index]) { last_inst = qir_MOV_dest(c, qir_reg(QFILE_NULL, 0), src); } - last_inst->sf = true; + + if (last_inst) + last_inst->sf = true; } #define OPTPASS(func) \