drm/amd/display: Check for NULL when creating gamma struct
authorKrunoslav Kovac <Krunoslav.Kovac@amd.com>
Wed, 2 Jan 2019 19:12:53 +0000 (14:12 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 14 Jan 2019 20:42:30 +0000 (15:42 -0500)
[Wjy&How] Some stress test is causing unexpected memory allocation
failure. This prevents null dereference but there will likely be problems
later, hard to gracefully handle memalloc fail for critical objects.

Signed-off-by: Krunoslav Kovac <Krunoslav.Kovac@amd.com>
Reviewed-by: Anthony Koo <Anthony.Koo@amd.com>
Acked-by: Leo Li <sunpeng.li@amd.com>
Acked-by: Reza Amini <Reza.Amini@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_surface.c

index c60c9b4c307531e118ecd4f986985dfa4388ad00..ee6bd50f60b8dcd59406556b2eeae51ab3be94de 100644 (file)
@@ -40,11 +40,14 @@ static void construct(struct dc_context *ctx, struct dc_plane_state *plane_state
        plane_state->ctx = ctx;
 
        plane_state->gamma_correction = dc_create_gamma();
-       plane_state->gamma_correction->is_identity = true;
+       if (plane_state->gamma_correction != NULL)
+               plane_state->gamma_correction->is_identity = true;
 
        plane_state->in_transfer_func = dc_create_transfer_func();
-       plane_state->in_transfer_func->type = TF_TYPE_BYPASS;
-       plane_state->in_transfer_func->ctx = ctx;
+       if (plane_state->in_transfer_func != NULL) {
+               plane_state->in_transfer_func->type = TF_TYPE_BYPASS;
+               plane_state->in_transfer_func->ctx = ctx;
+       }
 }
 
 static void destruct(struct dc_plane_state *plane_state)