drm/ttm: Fix a memory leak
Subsystems (3)
PATCH 1/1 drm/ttm: Fix a memory leak
Free the memory on failure.
Also no need to re-alloc memory on retry.
Signed-off-by xinhui pan <[email protected]>
--- drivers/gpu/drm/ttm/ttm_bo.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +6 -3
@@ -906,8 +906,10 @@ static int ttm_bo_bounce_temp_buffer(struct ttm_buffer_object *bo,return ret;/* move to the bounce domain */ ret =ttm_bo_handle_move_mem (bo, &hop_mem, false, ctx,NULL ); -if (ret) +if (ret) { +ttm_resource_free (bo, &hop_mem);return ret; + }return 0 ; }
@@ -938,18 +940,19 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,* stop and the driver will be called to make * the second hop. */ -bounce: ret =ttm_bo_mem_space (bo, placement, &mem, ctx);if (ret)return ret; +bounce: ret =ttm_bo_handle_move_mem (bo, &mem, false, ctx, &hop);if (ret == -EMULTIHOP ) { ret =ttm_bo_bounce_temp_buffer (bo, &mem, ctx, &hop);if (ret) -return ret; + goto out;/* try and move to final place now. */ goto bounce; } +out:if (ret)ttm_resource_free (bo, &mem);return ret;
Signature · 6 lines
2.25.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Hi Xinhui,
you also need to CC dri-devel for TTM patches, but apart from that it is a really good catch.
Am 19.02.21 um 05:25 schrieb xinhui pan:
Quoted 4 lines
Free the memory on failure.
Also no need to re-alloc memory on retry.Signed-off-by xinhui pan <[email protected]>
Reviewed-by Christian König <[email protected]>
CC [email protected] # 5.11
Going to push that to drm-misc-fixes in a Minute since that is a really important one.
Thanks,
Christian.
Quoted 32 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +4
-2@@ -906,8 +906,10 @@ static int ttm_bo_bounce_temp_buffer(struct ttm_buffer_object *bo,return ret;/* move to the bounce domain */ ret =ttm_bo_handle_move_mem (bo, &hop_mem, false, ctx,NULL ); -if (ret) +if (ret) { +ttm_resource_free (bo, &hop_mem);return ret; + }return 0 ; }@@ -938,18 +940,19 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,* stop and the driver will be called to make * the second hop. */ -bounce: ret =ttm_bo_mem_space (bo, placement, &mem, ctx);if (ret)return ret; +bounce: ret =ttm_bo_handle_move_mem (bo, &mem, false, ctx, &hop);if (ret == -EMULTIHOP ) { ret =ttm_bo_bounce_temp_buffer (bo, &mem, ctx, &hop);
drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_move_buffer(struct ttm_buffer_object *bo, · line 958
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_bo.c +2
-1if (ret) -return ret; + goto out;/* try and move to final place now. */ goto bounce; } +out:if (ret)ttm_resource_free (bo, &mem);return ret;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx