From 21c714f49474ca3f4ae73441e64aba80311c7302 Mon Sep 17 00:00:00 2001 From: Tvrtko Ursulin Date: Fri, 10 Apr 2026 19:54:59 +0100 Subject: [PATCH] plugins/amdgpu: Close dma-buf image file if the read fails Consolidate to one fclose() call with the extra bonus the inconsequential file descriptor leak is eliminated. Signed-off-by: Tvrtko Ursulin Reviewed-By: David Francis --- plugins/amdgpu/amdgpu_plugin_dmabuf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/amdgpu/amdgpu_plugin_dmabuf.c b/plugins/amdgpu/amdgpu_plugin_dmabuf.c index e76628cc2..312c9f95d 100644 --- a/plugins/amdgpu/amdgpu_plugin_dmabuf.c +++ b/plugins/amdgpu/amdgpu_plugin_dmabuf.c @@ -120,6 +120,7 @@ int amdgpu_plugin_dmabuf_restore(int id) } ret = read_fp(img_fp, buf, img_size); + fclose(img_fp); if (ret) { pr_perror("Unable to read from %s", path); xfree(buf); @@ -130,10 +131,8 @@ int amdgpu_plugin_dmabuf_restore(int id) if (rd == NULL) { pr_perror("Unable to parse the dmabuf message %d", id); xfree(buf); - fclose(img_fp); return -1; } - fclose(img_fp); /* Match GEM handle with shared_dmabuf list */ fd_id = amdgpu_id_for_handle(rd->gem_handle);