From 2be6ef9b349c883c87b5386e3361b523e2037a9f Mon Sep 17 00:00:00 2001 From: Mukul Joshi Date: Mon, 22 Jun 2026 10:54:16 -0400 Subject: [PATCH] drm/amdgpu: fix dma_buf leak in UALink exporter cleanup At export time the driver code always builds a dma_buf for the BO which is then shared for local imports. During cleanup, if there are no importers, which is true for local imports, we never free the dma_buf thus causing the memory leak. Fix by dropping the dma_buf reference in the no-importers branch as well. Signed-off-by: Mukul Joshi Reviewed-by: Harish Kasiviswanathan Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c index ebb30cac98b5..23cd6f564dd2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c @@ -2267,6 +2267,12 @@ static void amdgpu_ualink_exp_cleanup_worker(struct work_struct *work) /* If there are no importers for this BO/handle */ if (bitmap_empty(exp_xa_node->importers_bitmap, AMDGPU_UALINK_ACCEL_MAX)) { + /* Release the dma_buf created at export time (used for the + * local-import shortcut). The has-importers path below drops + * it too; this branch must not skip it or the dma_buf and the + * BO it pins are leaked. + */ + dma_buf_put(exp_xa_node->dmabuf); /* Drop the BO reference so it can be freed. */ amdgpu_bo_unref(&bo); exp_xa_node->bo = NULL;