Skip to content

Commit 4618666

Browse files
Lang Yualexdeucher
authored andcommitted
drm/amdgpu: refine error handling in amdgpu_ttm_tt_pin_userptr
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]>
1 parent d37bc6a commit 4618666

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,14 +812,16 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_device *bdev,
812812
/* Map SG to device */
813813
r = dma_map_sgtable(adev->dev, ttm->sg, direction, 0);
814814
if (r)
815-
goto release_sg;
815+
goto release_sg_table;
816816

817817
/* convert SG to linear array of pages and dma addresses */
818818
drm_prime_sg_to_dma_addr_array(ttm->sg, gtt->ttm.dma_address,
819819
ttm->num_pages);
820820

821821
return 0;
822822

823+
release_sg_table:
824+
sg_free_table(ttm->sg);
823825
release_sg:
824826
kfree(ttm->sg);
825827
ttm->sg = NULL;

0 commit comments

Comments
 (0)