[PATCH] drm/amdgpu: Fix double free of dmabuf
Christian König
christian.koenig at amd.com
Fri Nov 19 10:52:03 UTC 2021
Am 19.11.21 um 11:17 schrieb xinhui pan:
> amdgpu_amdkfd_gpuvm_free_memory_of_gpu drop dmabuf reference increased in
> amdgpu_gem_prime_export.
> amdgpu_bo_destroy drop dmabuf reference increased in
> amdgpu_gem_prime_import.
>
> So remove this extra dma_buf_put to avoid double free.
>
> Signed-off-by: xinhui pan <xinhui.pan at amd.com>
Yeah, Felix pinged me as well that the DMA-buf import code looks odd and
he is dropping the extra reference which didn't made much sense to me.
Acked-by: Christian König <christian.koenig at amd.com> for this patch for
now, but I'm going to take another look at this when I have time.
Regards,
Christian.
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> index 6c6d5d994b5d..0f68d28e002e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> @@ -665,12 +665,6 @@ kfd_mem_attach_dmabuf(struct amdgpu_device *adev, struct kgd_mem *mem,
> if (IS_ERR(gobj))
> return PTR_ERR(gobj);
>
> - /* Import takes an extra reference on the dmabuf. Drop it now to
> - * avoid leaking it. We only need the one reference in
> - * kgd_mem->dmabuf.
> - */
> - dma_buf_put(mem->dmabuf);
> -
> *bo = gem_to_amdgpu_bo(gobj);
> (*bo)->flags |= AMDGPU_GEM_CREATE_PREEMPTIBLE;
> (*bo)->parent = amdgpu_bo_ref(mem->bo);
More information about the amd-gfx
mailing list