panfrost: do not deref potentially null pointer

We need to check for failure to import *before* we dereference here.

Fixes: f94889d079 ("panfrost: Make pan_texture.{c,h} panfrost_bo agnostic")
CID: 1587376
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28856>
This commit is contained in:
Erik Faye-Lund 2024-04-22 13:29:13 +02:00 committed by Marge Bot
parent 186f7fa915
commit 8deaf37047

View file

@ -725,13 +725,14 @@ panfrost_resource_create_with_modifier(struct pipe_screen *screen,
}
assert(handle.type == WINSYS_HANDLE_TYPE_FD);
so->bo = panfrost_bo_import(dev, handle.handle);
so->image.data.base = so->bo->ptr.gpu;
close(handle.handle);
if (!so->bo) {
free(so);
return NULL;
}
so->image.data.base = so->bo->ptr.gpu;
} else {
/* We create a BO immediately but don't bother mapping, since we don't
* care to map e.g. FBOs which the CPU probably won't touch */