]> Git Repo - linux.git/commitdiff
drm/amdgpu: refine error handling in amdgpu_ttm_tt_pin_userptr
authorLang Yu <[email protected]>
Fri, 18 Oct 2024 09:21:09 +0000 (17:21 +0800)
committerAlex Deucher <[email protected]>
Thu, 24 Oct 2024 22:06:24 +0000 (18:06 -0400)
Free sg table when dma_map_sgtable() failed to avoid memory leak.

Signed-off-by: Lang Yu <[email protected]>
Reviewed-by: Alex Deucher <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

index 74adb983ab03e0877286a6524c08623bd55f3584..0637414fc70e02416cb50868761a885584c274cd 100644 (file)
@@ -812,7 +812,7 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_device *bdev,
        /* Map SG to device */
        r = dma_map_sgtable(adev->dev, ttm->sg, direction, 0);
        if (r)
-               goto release_sg;
+               goto release_sg_table;
 
        /* convert SG to linear array of pages and dma addresses */
        drm_prime_sg_to_dma_addr_array(ttm->sg, gtt->ttm.dma_address,
@@ -820,6 +820,8 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_device *bdev,
 
        return 0;
 
+release_sg_table:
+       sg_free_table(ttm->sg);
 release_sg:
        kfree(ttm->sg);
        ttm->sg = NULL;
This page took 0.060451 seconds and 4 git commands to generate.