]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/amdkfd: fix a potential ttm->sg memory leak
authorLang Yu <lang.yu@amd.com>
Wed, 29 Sep 2021 06:54:39 +0000 (14:54 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 5 Oct 2021 14:53:45 +0000 (10:53 -0400)
Memory is allocated for ttm->sg by kmalloc in kfd_mem_dmamap_userptr,
but isn't freed by kfree in kfd_mem_dmaunmap_userptr. Free it!

Fixes: a0591f662712 ("drm/amdgpu: Add multi-GPU DMA mapping helpers")
Signed-off-by: Lang Yu <lang.yu@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

index 2d6b2d77b73848e2e43144ca9ce94a5ec8c62a20..054c1a224defb8e6bce04523fd46978aab228108 100644 (file)
@@ -563,6 +563,7 @@ kfd_mem_dmaunmap_userptr(struct kgd_mem *mem,
 
        dma_unmap_sgtable(adev->dev, ttm->sg, direction, 0);
        sg_free_table(ttm->sg);
+       kfree(ttm->sg);
        ttm->sg = NULL;
 }