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: 88dc4db6be ("panfrost: Init/destroy blitter from per-gen file")
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reported-by: Icecream95 <ixn@disroot.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12512>
(cherry picked from commit 2d31d469f7)
This commit is contained in:
Alyssa Rosenzweig 2021-08-23 20:18:25 -04:00 committed by Dylan Baker
parent c90937aa10
commit ece6458c04
2 changed files with 3 additions and 2 deletions

View file

@ -238,7 +238,7 @@
"description": "panfrost: Fix NULL dereference in allowlist code",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "88dc4db6be7e21dee525ce1dd4e411664ebc33d6"
},

View file

@ -701,7 +701,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);