From 3c01205e32b14cfca36f8396d34150b152f46218 Mon Sep 17 00:00:00 2001 From: Mario Kleiner Date: Tue, 23 Sep 2025 03:15:17 +0100 Subject: [PATCH] asahi: Fix lseek failure error handling in agx_bo_import(). If bo->size = lseek(); would return a failure value of bo->size ==-1, then current error handling would return while leaving the already allocated and cached bo for the dmabuf fd in a half initialized "zombie" state. On a successive call to agx_bo_import() for the same fd, the assigned bo->size == -1 would mark the bo as "already initialized", just bumping its reference count, and then returning a dysfunctional bo to the caller, leasing to followup failures elsewhere. Use goto error; instead, where "error:" handling will zero-out the bo, marking it as effectively uninitialized, and hopefully causing proper initialization on a successive call to agx_bo_import(). Fixes: df725d4f642a ("asahi: remove agx_bo::dev") Signed-off-by: Mario Kleiner Part-of: --- src/asahi/lib/agx_device.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/asahi/lib/agx_device.c b/src/asahi/lib/agx_device.c index 35aa8a672e3..910ec08d5f9 100644 --- a/src/asahi/lib/agx_device.c +++ b/src/asahi/lib/agx_device.c @@ -283,8 +283,7 @@ agx_bo_import(struct agx_device *dev, int fd) * for zero sized maps and fail nicely too */ if ((bo->size == 0) || (bo->size == (size_t)-1)) { - pthread_mutex_unlock(&dev->bo_map_lock); - return NULL; + goto error; } if (bo->size & (AIL_PAGESIZE - 1)) { fprintf(