diff options
| author | Lang Yu <[email protected]> | 2024-10-18 09:21:09 +0000 |
|---|---|---|
| committer | Alex Deucher <[email protected]> | 2024-10-24 22:06:24 +0000 |
| commit | 46186667f98fb7158c98f4ff5da62c427761ffcd (patch) | |
| tree | 3142aac15f84fbb3cbfe081e0492a8d5fd6e3ec2 /drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |
| parent | drm/amdgpu: Fix the logic for NPS request failure (diff) | |
| download | kernel-46186667f98fb7158c98f4ff5da62c427761ffcd.tar.gz kernel-46186667f98fb7158c98f4ff5da62c427761ffcd.zip | |
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]>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 74adb983ab03..0637414fc70e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -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; |
