d3d12: Don't crash when libd3d12.so can't be found
authorJan Alexander Steffens (heftig) <heftig@archlinux.org>
Sun, 4 Dec 2022 00:17:57 +0000 (00:17 +0000)
committerEric Engestrom <eric@engestrom.ch>
Wed, 14 Dec 2022 20:47:00 +0000 (20:47 +0000)
`d3d12_destroy_screen` is called by `d3d12_create_dxcore_screen` after
`d3d12_init_screen_base` fails and attempts to call `util_dl_close` on
a NULL pointer, leading to an abort.

To fix this, only close the library after if it was actually opened.

Cc: mesa-stable
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20145>
(cherry picked from commit b3d1ae19f2f4d93cf0a5f45a598149ac4e8e05aa)

.pick_status.json
src/gallium/drivers/d3d12/d3d12_screen.cpp

index fa6bed0..c28142a 100644 (file)
         "description": "d3d12: Don't crash when libd3d12.so can't be found",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
index 1cbe1fb..c21c60e 100644 (file)
@@ -741,7 +741,8 @@ d3d12_destroy_screen(struct d3d12_screen *screen)
    slab_destroy_parent(&screen->transfer_pool);
    mtx_destroy(&screen->submit_mutex);
    mtx_destroy(&screen->descriptor_pool_mutex);
-   util_dl_close(screen->d3d12_mod);
+   if (screen->d3d12_mod)
+      util_dl_close(screen->d3d12_mod);
    glsl_type_singleton_decref();
    FREE(screen);
 }