Module: Mesa
Branch: main
Commit: af953616a10ad8b122b1d3906b855c0a5f9fbfa7
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=af953616a10ad8b122b1d3906b855c0a5f9fbfa7

Author: Yogesh Mohan Marimuthu <[email protected]>
Date:   Sat Mar  4 10:57:15 2023 +0530

wsi/display: check alloc failure in wsi_display_alloc_connector()

vulkancts test dEQP-VK.wsi.direct_drm.surface.create_simulate_oom is failing
because in wsi_display_alloc_connector() function memory allocation for
connector is not checked for return NULL. create_simulate_oom test simulates
out of memory, hence memory allocation fails for connector and later when
tried to dereference connector program will segfault.

This patch fixes the dEQP-VK.wsi.direct_drm.surface.create_simulate_oom test
segfault issue by checking if connector is NULL afer memory allocation.

Cc: mesa-stable
Reviewed-by: Eric Engestrom <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21701>

---

 src/vulkan/wsi/wsi_common_display.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/vulkan/wsi/wsi_common_display.c 
b/src/vulkan/wsi/wsi_common_display.c
index 6a27ae0d0a6..7a2a918e530 100644
--- a/src/vulkan/wsi/wsi_common_display.c
+++ b/src/vulkan/wsi/wsi_common_display.c
@@ -302,6 +302,8 @@ wsi_display_alloc_connector(struct wsi_display *wsi,
    struct wsi_display_connector *connector =
       vk_zalloc(wsi->alloc, sizeof (struct wsi_display_connector),
                 8, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+   if (!connector)
+      return NULL;
 
    connector->id = connector_id;
    connector->wsi = wsi;

Reply via email to