diff options
author | Alex Hung <[email protected]> | 2024-06-03 14:27:55 -0600 |
---|---|---|
committer | Alex Deucher <[email protected]> | 2024-06-19 12:44:47 -0400 |
commit | 7cf24de30e8ab875abc92a81ff227ab9e5f4282e (patch) | |
tree | 96efc22fe3b735ceaa0e09be729517b3a1464357 | |
parent | 470f3760cfe6dd2ce66cf9159e65876f7eb28792 (diff) |
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: Harry Wentland <[email protected]>
Acked-by: Hamza Mahfooz <[email protected]>
Signed-off-by: Alex Hung <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
4 files changed, 14 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index 76b849bdd914..87e84b0a3d48 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c @@ -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; diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c b/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c index a63b5dcba3f5..7abf8b88ca91 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c @@ -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); diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_utils.c b/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_utils.c index 87c7b13391bc..d276458e50fd 100644 --- a/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_utils.c +++ b/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_utils.c @@ -120,7 +120,8 @@ 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); - num_pipes = dml_ctx->config.callbacks.get_opp_heads_for_otg_master(otg_master_pipe, &context->res_ctx, dc_main_pipes); + 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); } /* if phantom exists, find associated pipes */ diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml2_dc_resource_mgmt.c b/drivers/gpu/drm/amd/display/dc/dml2/dml2_dc_resource_mgmt.c index 486b222083e0..6eccf0241d85 100644 --- a/drivers/gpu/drm/amd/display/dc/dml2/dml2_dc_resource_mgmt.c +++ b/drivers/gpu/drm/amd/display/dc/dml2/dml2_dc_resource_mgmt.c @@ -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); } |