uninitialized variable in dcn10 code

Harry Wentland harry.wentland at amd.com
Tue Nov 14 14:34:01 UTC 2017


On 2017-11-14 07:29 AM, Tom St Denis wrote:
> Hi Harry,
> 
> At display/dc/dcn10/dcn10_hw_sequencer.c:2140
> 
>     if (num_planes > 0) {
>         struct dc_stream_state *stream_for_cursor;
> 
>         program_all_pipe_in_tree(dc, top_pipe_to_program, context);
> 
>         for (i = 0; i < dc->res_pool->pipe_count; i++) {
>             struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
> 
>             if (stream == pipe_ctx->stream) {
>                 stream_for_cursor = pipe_ctx->stream;
>                 break;
>             }
>         }
> 
>         /* TODO: this is a hack w/a for switching from mpo to pipe split */
>         if (stream_for_cursor->cursor_attributes.address.quad_part != 0) {
>             struct dc_cursor_position position = { 0 };
> 
>             dc_stream_set_cursor_position(stream_for_cursor, &position);
>             dc_stream_set_cursor_attributes(stream_for_cursor,
>                 &stream_for_cursor->cursor_attributes);
>         }
>     }
> 
> The variable "stream_for_cursor" could be used uninitialized in the TODO block.  The pointer should be probably initialized to NULL at the top.
> 

Thanks, Tom. Gerrit decided not to push three commits when I merged the latest DC changes. I merged them now. Sorry for the churn. Fixed by this:

commit bec63856e26de10c1d3a3f1422acdb7e0719651f (HEAD -> amd-staging-drm-next, origin/amd-staging-drm-next)
Author: Leo (Sunpeng) Li <sunpeng.li at amd.com>
Date:   Wed Nov 8 15:30:19 2017 -0500

    drm/amd/display: Fix use before initialize warning
    
    on stream_for_cursor. Initialize to NULL.
    
    Change-Id: Ic032bfe78b33e466e560d33488e0fd8df060f694
    Signed-off-by: Leo (Sunpeng) Li <sunpeng.li at amd.com>
    Reviewed-by: Harry Wentland <Harry.Wentland at amd.com>

diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
index 30f458701f9c..b5d048b364a4 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
@@ -2124,7 +2124,7 @@ static void dcn10_apply_ctx_for_surface(
        }
 
        if (num_planes > 0) {
-               struct dc_stream_state *stream_for_cursor;
+               struct dc_stream_state *stream_for_cursor = NULL;
 
                program_all_pipe_in_tree(dc, top_pipe_to_program, context);

Harry

> Cheers,
> Tom


More information about the amd-gfx mailing list