From: Samuel Pitoiset Date: Sun, 12 Jul 2020 16:35:25 +0000 (+0200) Subject: radv: add missing return values check for some winsys calls X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7a61e31d7b2e9a486686740fad11d58745fa9cc9;p=mesa.git radv: add missing return values check for some winsys calls Make sure to handle errors properly. Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index c474c78eb21..8d28be4d92a 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -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); diff --git a/src/amd/vulkan/radv_sqtt.c b/src/amd/vulkan/radv_sqtt.c index e135e0c02cc..669c6fb197b 100644 --- a/src/amd/vulkan/radv_sqtt.c +++ b/src/amd/vulkan/radv_sqtt.c @@ -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; } }