radv: add missing return values check for some winsys calls
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Sun, 12 Jul 2020 16:35:25 +0000 (18:35 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 22 Jul 2020 15:06:20 +0000 (15:06 +0000)
Make sure to handle errors properly.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5872>

src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_sqtt.c

index c474c78eb21b165ebfa4190375ba87dfea371938..8d28be4d92a1424c1dd026aed98f55d55b4c35c5 100644 (file)
@@ -2722,6 +2722,9 @@ VkResult radv_CreateDevice(
 
        for (int family = 0; family < RADV_MAX_QUEUE_FAMILIES; ++family) {
                device->empty_cs[family] = device->ws->cs_create(device->ws, family);
+               if (!device->empty_cs[family])
+                       goto fail;
+
                switch (family) {
                case RADV_QUEUE_GENERAL:
                        radeon_emit(device->empty_cs[family], PKT3(PKT3_CONTEXT_CONTROL, 1, 0));
@@ -2733,7 +2736,10 @@ VkResult radv_CreateDevice(
                        radeon_emit(device->empty_cs[family], 0);
                        break;
                }
-               device->ws->cs_finalize(device->empty_cs[family]);
+
+               result = device->ws->cs_finalize(device->empty_cs[family]);
+               if (result != VK_SUCCESS)
+                       goto fail;
        }
 
        if (device->physical_device->rad_info.chip_class >= GFX7)
@@ -5639,6 +5645,7 @@ radv_timeline_add_point_locked(struct radv_device *device,
 
        struct radv_timeline_point *ret = NULL;
        struct radv_timeline_point *prev = NULL;
+       int r;
 
        if (p <= timeline->highest_signaled)
                return NULL;
@@ -5655,7 +5662,11 @@ radv_timeline_add_point_locked(struct radv_device *device,
 
        if (list_is_empty(&timeline->free_points)) {
                ret = malloc(sizeof(struct radv_timeline_point));
-               device->ws->create_syncobj(device->ws, false, &ret->syncobj);
+               r = device->ws->create_syncobj(device->ws, false, &ret->syncobj);
+               if (r) {
+                       free(ret);
+                       return NULL;
+               }
        } else {
                ret = list_first_entry(&timeline->free_points, struct radv_timeline_point, list);
                list_del(&ret->list);
index e135e0c02cccc067a8d942f17f69ada01354a1f9..669c6fb197b3927cea0060d92d5d8be13a5f606a 100644 (file)
@@ -401,10 +401,14 @@ static void
 radv_thread_trace_init_cs(struct radv_device *device)
 {
        struct radeon_winsys *ws = device->ws;
+       VkResult result;
 
        /* Thread trace start CS. */
        for (int family = 0; family < 2; ++family) {
                device->thread_trace_start_cs[family] = ws->cs_create(ws, family);
+               if (!device->thread_trace_start_cs[family])
+                       return;
+
                switch (family) {
                case RADV_QUEUE_GENERAL:
                        radeon_emit(device->thread_trace_start_cs[family], PKT3(PKT3_CONTEXT_CONTROL, 1, 0));
@@ -434,12 +438,17 @@ radv_thread_trace_init_cs(struct radv_device *device)
                                             device->thread_trace_start_cs[family],
                                             family);
 
-               ws->cs_finalize(device->thread_trace_start_cs[family]);
+               result = ws->cs_finalize(device->thread_trace_start_cs[family]);
+               if (result != VK_SUCCESS)
+                       return;
        }
 
        /* Thread trace stop CS. */
        for (int family = 0; family < 2; ++family) {
                device->thread_trace_stop_cs[family] = ws->cs_create(ws, family);
+               if (!device->thread_trace_stop_cs[family])
+                       return;
+
                switch (family) {
                case RADV_QUEUE_GENERAL:
                        radeon_emit(device->thread_trace_stop_cs[family], PKT3(PKT3_CONTEXT_CONTROL, 1, 0));
@@ -469,7 +478,9 @@ radv_thread_trace_init_cs(struct radv_device *device)
                                          device->thread_trace_stop_cs[family],
                                          false);
 
-               ws->cs_finalize(device->thread_trace_stop_cs[family]);
+               result = ws->cs_finalize(device->thread_trace_stop_cs[family]);
+               if (result != VK_SUCCESS)
+                       return;
        }
 }