mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
drm/amdgpu: refine error handling in amdgpu_ttm_tt_pin_userptr
[ Upstream commit 46186667f98fb7158c98f4ff5da62c427761ffcd ] Free sg table when dma_map_sgtable() failed to avoid memory leak. Signed-off-by: Lang Yu <lang.yu@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8ffd84c694
commit
b295b197da
@@ -776,7 +776,7 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_device *bdev,
|
|||||||
/* Map SG to device */
|
/* Map SG to device */
|
||||||
r = dma_map_sgtable(adev->dev, ttm->sg, direction, 0);
|
r = dma_map_sgtable(adev->dev, ttm->sg, direction, 0);
|
||||||
if (r)
|
if (r)
|
||||||
goto release_sg;
|
goto release_sg_table;
|
||||||
|
|
||||||
/* convert SG to linear array of pages and dma addresses */
|
/* convert SG to linear array of pages and dma addresses */
|
||||||
drm_prime_sg_to_dma_addr_array(ttm->sg, gtt->ttm.dma_address,
|
drm_prime_sg_to_dma_addr_array(ttm->sg, gtt->ttm.dma_address,
|
||||||
@@ -784,6 +784,8 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_device *bdev,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
release_sg_table:
|
||||||
|
sg_free_table(ttm->sg);
|
||||||
release_sg:
|
release_sg:
|
||||||
kfree(ttm->sg);
|
kfree(ttm->sg);
|
||||||
ttm->sg = NULL;
|
ttm->sg = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user