Mesa (staging/20.0): pan/midgard: Don't crash with constants on unknown ops

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Feb 19 17:20:03 UTC 2020


Module: Mesa
Branch: staging/20.0
Commit: 01dab4b7feef6575cff55187cedee1d3f0609079
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=01dab4b7feef6575cff55187cedee1d3f0609079

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Thu Feb 13 17:12:51 2020 -0500

pan/midgard: Don't crash with constants on unknown ops

Just use a dummy name instead.. we can't know a priori what type an
unknown op will consume, but we don't want to dereference a null
pointer.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Fixes: 24360966ab3 ("panfrost/midgard: Prettify embedded constant
prints")

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3835>
(cherry picked from commit 6af14d3685fac433193b92f9ad6c9f8a3eaf87ff)

---

 .pick_status.json                    | 2 +-
 src/panfrost/midgard/midgard_print.c | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index 91cabcf0d3f..fdb942db30f 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -553,7 +553,7 @@
         "description": "pan/midgard: Don't crash with constants on unknown ops",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "24360966ab31a9bedfe07356413769218fd2e0b6"
     },
diff --git a/src/panfrost/midgard/midgard_print.c b/src/panfrost/midgard/midgard_print.c
index 85a1d981722..94a0f1a6453 100644
--- a/src/panfrost/midgard/midgard_print.c
+++ b/src/panfrost/midgard/midgard_print.c
@@ -110,6 +110,10 @@ mir_print_constant_component(FILE *fp, const midgard_constants *consts, unsigned
         bool is_sint = false, is_uint = false, is_hex = false;
         const char *opname = alu_opcode_props[op].name;
 
+        /* Add a sentinel name to prevent crashing */
+        if (!opname)
+                opname = "unknown";
+
         if (opname[0] == 'u') {
                 /* If the opcode starts with a 'u' we are sure we deal with an
                  * unsigned int operation



More information about the mesa-commit mailing list