[26/39] drm/amd/dal: Memory leak fixes

Submitted by Harry Wentland on Nov. 24, 2016, 2:02 a.m.

Details

Message ID 20161124020308.28124-27-harry.wentland@amd.com
State New
Headers show
Series "dal patches for nov 23, 2016" ( rev: 1 ) in AMD X.Org drivers

Commit Message

Harry Wentland Nov. 24, 2016, 2:02 a.m.
From: Leon Elazar <leon.elazar@amd.com>

[Problem]
DC Hw sequencer wansn't released during the destructor.
DC Context was set to NULL before was actually released.

Change-Id: If2c0caf0cc49d2f023adcdb083ef869d8712326d
Signed-off-by: Leon Elazar <leon.elazar@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
---
 drivers/gpu/drm/amd/dal/dc/core/dc.c          |  6 +++---
 drivers/gpu/drm/amd/dal/dc/core/dc_resource.c | 10 ++++++++++
 drivers/gpu/drm/amd/dal/dc/inc/resource.h     |  3 +--
 3 files changed, 14 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc.c b/drivers/gpu/drm/amd/dal/dc/core/dc.c
index 7b11cb0ee737..c42d0d49ca92 100644
--- a/drivers/gpu/drm/amd/dal/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/dal/dc/core/dc.c
@@ -455,8 +455,7 @@  static void destruct(struct core_dc *dc)
 
 	destroy_links(dc);
 
-	if (dc->res_pool)
-		dc->res_pool->funcs->destroy(&dc->res_pool);
+	dc_destroy_resource_pool(dc);
 
 	if (dc->ctx->gpio_service)
 		dal_gpio_service_destroy(&dc->ctx->gpio_service);
@@ -471,8 +470,9 @@  static void destruct(struct core_dc *dc)
 		dal_logger_destroy(&dc->ctx->logger);
 
 	dm_free(dc->current_context);
-	dm_free(dc->ctx);
+	dc->current_context = NULL;
 
+	dm_free(dc->ctx);
 	dc->ctx = NULL;
 }
 
diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc_resource.c b/drivers/gpu/drm/amd/dal/dc/core/dc_resource.c
index a9b2784f8168..bd53d27e5414 100644
--- a/drivers/gpu/drm/amd/dal/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/dal/dc/core/dc_resource.c
@@ -98,6 +98,16 @@  struct resource_pool *dc_create_resource_pool(
 	return false;
 }
 
+void dc_destroy_resource_pool(struct core_dc *dc)
+{
+	if (dc) {
+		if (dc->res_pool)
+			dc->res_pool->funcs->destroy(&dc->res_pool);
+
+		if (dc->hwseq)
+			dm_free(dc->hwseq);
+	}
+}
 
 static void update_num_audio(
 	const struct resource_straps *straps,
diff --git a/drivers/gpu/drm/amd/dal/dc/inc/resource.h b/drivers/gpu/drm/amd/dal/dc/inc/resource.h
index 33fb7d98b294..dae94706e5da 100644
--- a/drivers/gpu/drm/amd/dal/dc/inc/resource.h
+++ b/drivers/gpu/drm/amd/dal/dc/inc/resource.h
@@ -76,8 +76,7 @@  struct resource_pool *dc_create_resource_pool(
 				enum dce_version dc_version,
 				struct hw_asic_id asic_id);
 
-void dc_destroy_resource_pool(struct resource_pool **pool,
-				enum dce_version dc_version);
+void dc_destroy_resource_pool(struct core_dc *dc);
 
 enum dc_status resource_map_pool_resources(
 		const struct core_dc *dc,