aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/0363-drm-amd-display-fix-memory-leak.patch
blob: 537f9d26ca3a11ee8fba2c46ac816e01004095b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
From 737c88865f78725772f21cd565f4af8f777065e8 Mon Sep 17 00:00:00 2001
From: Dmytro Laktyushkin <Dmytro.Laktyushkin@amd.com>
Date: Tue, 18 Apr 2017 17:31:46 -0400
Subject: [PATCH 0363/4131] drm/amd/display: fix memory leak

Signed-off-by: Dmytro Laktyushkin <Dmytro.Laktyushkin@amd.com>
Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index b1f0a50..1dd9c73 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -918,7 +918,6 @@ bool dc_post_update_surfaces_to_stream(struct dc *dc)
 	int i;
 	struct core_dc *core_dc = DC_TO_CORE(dc);
 	struct validate_context *context = dm_alloc(sizeof(struct validate_context));
-	bool result = true;
 
 	if (!context) {
 		dm_error("%s: failed to create validate ctx\n", __func__);
@@ -927,28 +926,29 @@ bool dc_post_update_surfaces_to_stream(struct dc *dc)
 	dc_resource_validate_ctx_copy_construct(core_dc->current_context, context);
 
 	post_surface_trace(dc);
+
 	for (i = 0; i < context->res_ctx.pool->pipe_count; i++)
 		if (context->res_ctx.pipe_ctx[i].stream == NULL) {
 			context->res_ctx.pipe_ctx[i].pipe_idx = i;
 			core_dc->hwss.power_down_front_end(
 					core_dc, &context->res_ctx.pipe_ctx[i]);
 		}
-
 	if (!core_dc->res_pool->funcs->validate_bandwidth(core_dc, context)) {
 		BREAK_TO_DEBUGGER();
-		result = false;
-		goto cleanup;
+		dc_resource_validate_ctx_destruct(context);
+		dm_free(context);
+		return false;
 	}
 
 	core_dc->hwss.set_bandwidth(core_dc, context, true);
 
-	dc_resource_validate_ctx_copy_construct(context, core_dc->current_context);
-
-cleanup:
-	dc_resource_validate_ctx_destruct(context);
-	dm_free(context);
+	if (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;
+	return true;
 }
 
 bool dc_commit_surfaces_to_stream(
@@ -1440,10 +1440,8 @@ void dc_update_surfaces_and_stream(struct dc *dc,
 	return;
 
 fail:
-	if (core_dc->current_context != context) {
-		dc_resource_validate_ctx_destruct(context);
-		dm_free(context);
-	}
+	dc_resource_validate_ctx_destruct(context);
+	dm_free(context);
 }
 
 uint8_t dc_get_current_stream_count(const struct dc *dc)
-- 
2.7.4