[PATCH 67/95] drm/amdgpu: fix dma_buf leak in UALink exporter cleanup
Alex Deucher <[email protected]>
| Newsgroups | org.freedesktop.lists.amd-gfx |
|---|---|
| Message-ID | <[email protected]> |
From: Mukul Joshi <[email protected]> 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 <[email protected]> Reviewed-by: Harish Kasiviswanathan <[email protected]> Signed-off-by: Alex Deucher <[email protected]> --- 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 66ae6a0f1c53b..dd45c2e20be0a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c @@ -2220,6 +2220,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; -- 2.55.0