Commit 7cf24de3 authored by Alex Hung's avatar Alex Hung Committed by Alex Deucher

drm/amd/display: Check pipe_ctx before it is used

resource_get_odm_slice_count and resource_get_otg_master_for_stream can
return null, and their returns must be checked before used.

This fixes 4 NULL_RETURNS issues reported by Coverity.
Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
Acked-by: default avatarHamza Mahfooz <hamza.mahfooz@amd.com>
Signed-off-by: default avatarAlex Hung <alex.hung@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 470f3760
......@@ -3127,9 +3127,14 @@ bool resource_update_pipes_for_stream_with_slice_count(
int i;
struct pipe_ctx *otg_master = resource_get_otg_master_for_stream(
&new_ctx->res_ctx, stream);
int cur_slice_count = resource_get_odm_slice_count(otg_master);
int cur_slice_count;
bool result = true;
if (!otg_master)
return false;
cur_slice_count = resource_get_odm_slice_count(otg_master);
if (new_slice_count == cur_slice_count)
return result;
......
......@@ -1177,6 +1177,9 @@ static void init_pipe_slice_table_from_context(
stream = context->streams[i];
otg_master = resource_get_otg_master_for_stream(
&context->res_ctx, stream);
if (!otg_master)
continue;
count = resource_get_odm_slice_count(otg_master);
update_slice_table_for_stream(table, stream, count);
......
......@@ -120,6 +120,7 @@ int dml21_find_dc_pipes_for_plane(const struct dc *in_dc,
} else {
/* stream was configured with dummy plane, so get pipes from opp head */
struct pipe_ctx *otg_master_pipe = dml_ctx->config.callbacks.get_otg_master_for_stream(&context->res_ctx, dc_main_stream);
if (otg_master_pipe != NULL)
num_pipes = dml_ctx->config.callbacks.get_opp_heads_for_otg_master(otg_master_pipe, &context->res_ctx, dc_main_pipes);
}
......
......@@ -905,6 +905,9 @@ static unsigned int get_source_odm_factor(const struct dml2_context *ctx,
{
struct pipe_ctx *otg_master = ctx->config.callbacks.get_otg_master_for_stream(&state->res_ctx, stream);
if (!otg_master)
return 0;
return ctx->config.callbacks.get_odm_slice_count(otg_master);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment