uninitialized variable in dcn10 code

Michel Dänzer michel at daenzer.net
Tue Nov 14 14:33:39 UTC 2017


On 14/11/17 01:29 PM, 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.

BTW, the compiler points this out:

drivers/gpu/drm//amd/amdgpu/../display/dc/dcn10/dcn10_hw_sequencer.c: In function ‘dcn10_apply_ctx_for_surface’:
drivers/gpu/drm//amd/amdgpu/../display/dc/dcn10/dcn10_hw_sequencer.c:2146:5: warning: ‘stream_for_cursor’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     &stream_for_cursor->cursor_attributes);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the amd-gfx mailing list