Skip to contentSkip to conversation

drm/amd: Initialize remove_mpcc in dcn201_update_mpcc()

PATCH Applied Nathan Chancellor 2 participants 2 messages Sep 30, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd: Initialize remove_mpcc in dcn201_update_mpcc()

Clang warns:

drivers/gpu/drm/amd/amdgpu/../display/dc/dcn201/dcn201_hwseq.c:505:6: error: variable 'remove_mpcc' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

        if (mpc->funcs->get_mpcc_for_dpp_from_secondary)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn201/dcn201_hwseq.c:509:6: note: uninitialized use occurs here
        if (remove_mpcc != NULL && mpc->funcs->remove_mpcc_from_secondary)
            ^~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn201/dcn201_hwseq.c:505:2: note: remove the 'if' if its condition is always true
        if (mpc->funcs->get_mpcc_for_dpp_from_secondary)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn201/dcn201_hwseq.c:442:26: note: initialize the variable 'remove_mpcc' to silence this warning
        struct mpcc *remove_mpcc;
                                ^
                                 = NULL

1 error generated.

The code already handles remove_mpcc being NULL just fine so initialize it to NULL at the beginning of the function so it is never used uninitialized.

Fixes ff7e396f822f ("drm/amd/display: add cyan_skillfish display support")
---
 drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c +1 -1
index ceaaeeb8f2de..cfd09b3f705e 100644
@@ -439,7 +439,7 @@ void dcn201_update_mpcc(struct dc *dc, struct pipe_ctx *pipe_ctx)
 	bool per_pixel_alpha = pipe_ctx->plane_state->per_pixel_alpha && pipe_ctx->bottom_pipe;
 	int mpcc_id, dpp_id;
 	struct mpcc *new_mpcc;
-	struct mpcc *remove_mpcc;
+	struct mpcc *remove_mpcc = NULL;
 	struct mpc *mpc = dc->res_pool->mpc;
 	struct mpc_tree *mpc_tree_params = &(pipe_ctx->stream_res.opp->mpc_tree_params);
 

base-commit: 30fc33064c846df29888c3c61e30a064aad3a342

Signature · 1 line
2.33.0.591.gddb1055343
Applied
#1 lore raw

Applied. Thanks!

Alex

Quoted 47 lines · Nathan Chancellor

Clang warns:

drivers/gpu/drm/amd/amdgpu/../display/dc/dcn201/dcn201_hwseq.c:505:6: error: variable 'remove_mpcc' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

        if (mpc->funcs->get_mpcc_for_dpp_from_secondary)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn201/dcn201_hwseq.c:509:6: note: uninitialized use occurs here
        if (remove_mpcc != NULL && mpc->funcs->remove_mpcc_from_secondary)
            ^~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn201/dcn201_hwseq.c:505:2: note: remove the 'if' if its condition is always true
        if (mpc->funcs->get_mpcc_for_dpp_from_secondary)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn201/dcn201_hwseq.c:442:26: note: initialize the variable 'remove_mpcc' to silence this warning
        struct mpcc *remove_mpcc;
                                ^
                                 = NULL

1 error generated.

The code already handles remove_mpcc being NULL just fine so initialize it to NULL at the beginning of the function so it is never used uninitialized.

Fixes ff7e396f822f ("drm/amd/display: add cyan_skillfish display support")
---
 drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c +1 -1
index ceaaeeb8f2de..cfd09b3f705e 100644
@@ -439,7 +439,7 @@ void dcn201_update_mpcc(struct dc *dc, struct pipe_ctx *pipe_ctx)
        bool per_pixel_alpha = pipe_ctx->plane_state->per_pixel_alpha && pipe_ctx->bottom_pipe;
        int mpcc_id, dpp_id;
        struct mpcc *new_mpcc;
-       struct mpcc *remove_mpcc;
+       struct mpcc *remove_mpcc = NULL;
        struct mpc *mpc = dc->res_pool->mpc;
        struct mpc_tree *mpc_tree_params = &(pipe_ctx->stream_res.opp->mpc_tree_params);
 

base-commit: 30fc33064c846df29888c3c61e30a064aad3a342 --
2.33.0.591.gddb1055343