[PATCH 50/81] drm/amd/display: Fix context copy memory leak

sunpeng.li at amd.com sunpeng.li at amd.com
Tue Jul 25 13:54:10 UTC 2017


From: Corbin McElhanney <corbin.mcelhanney at amd.com>

This change corrects an error introduced in 355f123f. Instead of
using the copy constructor to assign the new context, we swap the
pointer.

Change-Id: Ic765e1ce78cd9f731486c1c44ad10c9c95f2c8ad
Signed-off-by: Corbin McElhanney <corbin.mcelhanney at amd.com>
Reviewed-by: Dmytro Laktyushkin <Dmytro.Laktyushkin at amd.com>
Acked-by: Harry Wentland <Harry.Wentland at amd.com>
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 52077d3..4f93029 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -972,7 +972,9 @@ static bool dc_commit_context_no_check(struct dc *dc, struct validate_context *c
 
 	dc_enable_stereo(dc, context, dc_streams, context->stream_count);
 
-	dc_resource_validate_ctx_copy_construct(context, core_dc->current_context);
+	dc_resource_validate_ctx_destruct(core_dc->current_context);
+	dm_free(core_dc->current_context);
+	core_dc->current_context = context;
 
 	return (result == DC_OK);
 }
@@ -1057,9 +1059,6 @@ bool dc_commit_streams(
 
 	result = dc_commit_context_no_check(dc, context);
 
-	dc_resource_validate_ctx_destruct(context);
-	dm_free(context);
-
 	return (result == DC_OK);
 
 fail:
-- 
2.7.4



More information about the amd-gfx mailing list