Mesa (main): panfrost: Fix NULL dereference in allowlist code

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Aug 24 00:52:42 UTC 2021


Module: Mesa
Branch: main
Commit: 2d31d469f771b5ef617c88b8b50dff97288284fe
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2d31d469f771b5ef617c88b8b50dff97288284fe

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Mon Aug 23 20:18:25 2021 -0400

panfrost: Fix NULL dereference in allowlist code

If a user attempts to run Panfrost on an unsupported GPU (e.g. Mali
T604), Panfrost will refuse to load and will destroy the screen
immediately, allowing for a graceful fallback to a software rasterizer.
However, the screen destroy code calls a screen_destroy function in the
GenXML vtbl -- and this function is still NULL when the allowlist is
checked. This manifests as crashes on unsuported GPUs.

Issue tracked down with Icecream95's mad Ghidra skills.

Closes: #5269
Fixes: 88dc4db6be7 ("panfrost: Init/destroy blitter from per-gen file")
Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Reported-by: Icecream95 <ixn at disroot.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12512>

---

 src/gallium/drivers/panfrost/pan_screen.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c
index 15e01ea4ff9..340f74041b6 100644
--- a/src/gallium/drivers/panfrost/pan_screen.c
+++ b/src/gallium/drivers/panfrost/pan_screen.c
@@ -703,7 +703,8 @@ panfrost_destroy_screen(struct pipe_screen *pscreen)
         panfrost_pool_cleanup(&screen->blitter.desc_pool);
         pan_blend_shaders_cleanup(dev);
 
-        screen->vtbl.screen_destroy(pscreen);
+        if (screen->vtbl.screen_destroy)
+                screen->vtbl.screen_destroy(pscreen);
 
         if (dev->ro)
                 dev->ro->destroy(dev->ro);



More information about the mesa-commit mailing list