]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/display: Check pipe_ctx before it is used
authorAlex Hung <alex.hung@amd.com>
Mon, 3 Jun 2024 20:27:55 +0000 (14:27 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 19 Jun 2024 16:44:47 +0000 (12:44 -0400)
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 <harry.wentland@amd.com>
Acked-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_resource.c
drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c
drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_utils.c
drivers/gpu/drm/amd/display/dc/dml2/dml2_dc_resource_mgmt.c

index 76b849bdd914b8d65381a7476c66bf90fa10fca0..87e84b0a3d4896e6bbebde58c7065eee5e02a1f8 100644 (file)
@@ -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;
 
index a63b5dcba3f50c1ca6023775aa4cbc274ebf8d53..7abf8b88ca919e8b9f1418134b2d049504ff6f0e 100644 (file)
@@ -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);
 
index 87c7b13391bc2537c1151254e4b51ee2fd527513..d276458e50fdef050ba951132f3397f5929f7271 100644 (file)
@@ -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 */
index 486b222083e0ea47e58e386338dde35978a62193..6eccf0241d857d89031224900d9063460d76472f 100644 (file)
@@ -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);
 }