Browse Source

drm/amd/display: Fix memory leak in post_update_surfaces

Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Harry Wentland 8 years ago
parent
commit
50f27269b8
1 changed files with 5 additions and 2 deletions
  1. 5 2
      drivers/gpu/drm/amd/display/dc/core/dc.c

+ 5 - 2
drivers/gpu/drm/amd/display/dc/core/dc.c

@@ -918,6 +918,7 @@ bool dc_post_update_surfaces_to_stream(struct dc *dc)
 	int i;
 	int i;
 	struct core_dc *core_dc = DC_TO_CORE(dc);
 	struct core_dc *core_dc = DC_TO_CORE(dc);
 	struct validate_context *context = dm_alloc(sizeof(struct validate_context));
 	struct validate_context *context = dm_alloc(sizeof(struct validate_context));
+	bool result = true;
 
 
 	if (!context) {
 	if (!context) {
 		dm_error("%s: failed to create validate ctx\n", __func__);
 		dm_error("%s: failed to create validate ctx\n", __func__);
@@ -935,17 +936,19 @@ bool dc_post_update_surfaces_to_stream(struct dc *dc)
 
 
 	if (!core_dc->res_pool->funcs->validate_bandwidth(core_dc, context)) {
 	if (!core_dc->res_pool->funcs->validate_bandwidth(core_dc, context)) {
 		BREAK_TO_DEBUGGER();
 		BREAK_TO_DEBUGGER();
-		return false;
+		result = false;
+		goto cleanup;
 	}
 	}
 
 
 	core_dc->hwss.set_bandwidth(core_dc, context, true);
 	core_dc->hwss.set_bandwidth(core_dc, context, true);
 
 
 	dc_resource_validate_ctx_copy_construct(context, core_dc->current_context);
 	dc_resource_validate_ctx_copy_construct(context, core_dc->current_context);
 
 
+cleanup:
 	dc_resource_validate_ctx_destruct(context);
 	dc_resource_validate_ctx_destruct(context);
 	dm_free(context);
 	dm_free(context);
 
 
-	return true;
+	return result;
 }
 }
 
 
 bool dc_commit_surfaces_to_stream(
 bool dc_commit_surfaces_to_stream(