* [PATCH] drm/amdgpu: refine error handling in amdgpu_ttm_tt_pin_userptr
@ 2024-10-18 9:46 Lang Yu
2024-10-18 15:08 ` Alex Deucher
0 siblings, 1 reply; 2+ messages in thread
From: Lang Yu @ 2024-10-18 9:46 UTC (permalink / raw)
To: amd-gfx; +Cc: Christian Koenig, Lang Yu
Free sg table when dma_map_sgtable() failed to avoid memory leak.
Signed-off-by: Lang Yu <lang.yu@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/amdgpu: refine error handling in amdgpu_ttm_tt_pin_userptr
2024-10-18 9:46 [PATCH] drm/amdgpu: refine error handling in amdgpu_ttm_tt_pin_userptr Lang Yu
@ 2024-10-18 15:08 ` Alex Deucher
0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2024-10-18 15:08 UTC (permalink / raw)
To: Lang Yu; +Cc: amd-gfx, Christian Koenig
On Fri, Oct 18, 2024 at 5:46 AM Lang Yu <lang.yu@amd.com> wrote:
>
> 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>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> 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;
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-18 15:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-18 9:46 [PATCH] drm/amdgpu: refine error handling in amdgpu_ttm_tt_pin_userptr Lang Yu
2024-10-18 15:08 ` Alex Deucher
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.