[PATCH 05/10] drm/amd/display: Don't use target before null check

Harry Wentland harry.wentland at amd.com
Thu Dec 29 18:29:38 UTC 2016


It might blow up.

Change-Id: If7ff505e8387477f0466ba1a0a19fe5967996ed1
Signed-off-by: Harry Wentland <harry.wentland at amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng at amd.com>
Acked-by: Harry Wentland <Harry.Wentland at amd.com>
---
 drivers/gpu/drm/amd/display/dc/core/dc_target.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_target.c b/drivers/gpu/drm/amd/display/dc/core/dc_target.c
index d4ecf2da26d2..2d25b00b4bff 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_target.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_target.c
@@ -151,9 +151,9 @@ bool dc_target_set_cursor_attributes(
 	const struct dc_cursor_attributes *attributes)
 {
 	int i, j;
-	struct core_target *target = DC_TARGET_TO_CORE(dc_target);
-	struct core_dc *core_dc = DC_TO_CORE(target->ctx->dc);
-	struct resource_context *res_ctx = &core_dc->current_context->res_ctx;
+	struct core_target *target;
+	struct core_dc *core_dc;
+	struct resource_context *res_ctx;
 	bool ret = false;
 
 	if (NULL == dc_target) {
@@ -165,6 +165,10 @@ bool dc_target_set_cursor_attributes(
 			return false;
 	}
 
+	target = DC_TARGET_TO_CORE(dc_target);
+	core_dc = DC_TO_CORE(target->ctx->dc);
+	res_ctx = &core_dc->current_context->res_ctx;
+
 	for (i = 0; i < dc_target->stream_count; i++) {
 		const struct dc_stream *stream = dc_target->streams[i];
 
-- 
2.9.3



More information about the amd-gfx mailing list