From af8923bb01a27271f9943cbfaf8576253c4df2fb Mon Sep 17 00:00:00 2001 From: Icenowy Zheng Date: Wed, 18 Mar 2026 23:31:49 +0800 Subject: [PATCH] zink: skip all post-process when importing and resource_create fails When the pipe_resource pointer returned by resource_create is NULL, the process importing the handle into the underlying Vulkan driver is known to have failed, and the handle importing process shouldn't continue. Just return NULL in this case to prevent further check of pres being non-NULL. This also fixes the issue that renderonly code lacks check for non-NULL pres, and the conversion of pipe_resource to zink_resource in renderonly codepath is now gone because of a converted zink_resource is available above. Signed-off-by: Icenowy Zheng Part-of: --- src/gallium/drivers/zink/zink_resource.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 834bfeac433..b6374734beb 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -2129,20 +2129,19 @@ zink_resource_from_handle(struct pipe_screen *pscreen, } templ2.bind |= ZINK_BIND_DMABUF; struct pipe_resource *pres = resource_create(pscreen, &templ2, whandle, usage, &modifier, modifier_count, NULL, NULL); - if (pres) { - struct zink_resource *res = zink_resource(pres); - if (pres->target != PIPE_BUFFER) - res->valid = true; - else - tc_buffer_disable_cpu_storage(pres); - res->obj->immutable_handle = true; - res->internal_format = whandle->format; - } + if (!pres) + return NULL; + + struct zink_resource *res = zink_resource(pres); + if (pres->target != PIPE_BUFFER) + res->valid = true; + else + tc_buffer_disable_cpu_storage(pres); + res->obj->immutable_handle = true; + res->internal_format = whandle->format; #ifdef HAVE_LIBDRM if (screen->ro) { - struct zink_resource *res = zink_resource(pres); - /* Make sure that renderonly has a handle to our buffer in the display's * fd, so that a later renderonly_get_handle() returns correct handles * or GEM names.