panfrost: Don't double-free when handling error for unsupported GPU

Setting the screen ro member before we checked gpu id means the error
case leads to a double-free because screen->ro is set and allocated
by parent who hanbdles de-alloc a second time after we destroyed the
screen we just created because ro was set.

Cc: mesa-stable

Signed-off-by: Carsten Haitzler <carsten.haitzler@foss.arm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14516>
(cherry picked from commit 874f4095c5)
This commit is contained in:
Carsten Haitzler 2022-01-12 15:36:13 +00:00 committed by Eric Engestrom
parent d0e7882abd
commit e91c5034a7
2 changed files with 3 additions and 3 deletions

View file

@ -4657,7 +4657,7 @@
"description": "panfrost: Don't double-free when handling error for unsupported GPU",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -841,8 +841,6 @@ panfrost_create_screen(int fd, struct renderonly *ro)
if (dev->debug & PAN_DBG_NO_AFBC)
dev->has_afbc = false;
dev->ro = ro;
/* Check if we're loading against a supported GPU model. */
switch (dev->gpu_id) {
@ -862,6 +860,8 @@ panfrost_create_screen(int fd, struct renderonly *ro)
return NULL;
}
dev->ro = ro;
screen->base.destroy = panfrost_destroy_screen;
screen->base.get_name = panfrost_get_name;