zink: fix crashing on bo allocation failure
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 15 Jul 2022 15:21:34 +0000 (11:21 -0400)
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 20 Jul 2022 13:21:30 +0000 (09:21 -0400)
list init occurs after mem allocation, so check this first

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17639>

src/gallium/drivers/zink/zink_bo.c

index d4e739b..86b0e68 100644 (file)
@@ -126,7 +126,7 @@ bo_destroy(struct zink_screen *screen, struct pb_buffer *pbuf)
    struct zink_bo *bo = zink_bo(pbuf);
 
 #ifdef ZINK_USE_DMABUF
-   if (!bo->u.real.use_reusable_pool) {
+   if (bo->mem && !bo->u.real.use_reusable_pool) {
       simple_mtx_lock(&bo->u.real.export_lock);
       list_for_each_entry_safe(struct bo_export, export, &bo->u.real.exports, link) {
          struct drm_gem_close args = { .handle = export->gem_handle };