Skip to content

Commit

Permalink
drm/amd/powerplay: initialize a variable before using it
Browse files Browse the repository at this point in the history
Function vega10_apply_state_adjust_rules() only initializes
stable_pstate_sclk_dpm_percentage when
data->registry_data.stable_pstate_sclk_dpm_percentage is not between 1
and 100. The variable is then used to compute stable_pstate_sclk, which
therefore uses an uninitialized value.

Fix this by initializing stable_pstate_sclk_dpm_percentage to
data->registry_data.stable_pstate_sclk_dpm_percentage.

This issue has been found while building the kernel with clang. The
compiler reported a -Wsometimes-uninitialized warning.

Reviewed-by: Alex Deucher <[email protected]>
Fixes: f83a999 ("drm/amd/powerplay: add Vega10 powerplay support (v5)")
Signed-off-by: Nicolas Iooss <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
  • Loading branch information
fishilico authored and alexdeucher committed Nov 7, 2017
1 parent 1d864b8 commit 0d1da3c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3138,6 +3138,8 @@ static int vega10_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,
minimum_clocks.memoryClock = hwmgr->display_config.min_mem_set_clock;

if (PP_CAP(PHM_PlatformCaps_StablePState)) {
stable_pstate_sclk_dpm_percentage =
data->registry_data.stable_pstate_sclk_dpm_percentage;
PP_ASSERT_WITH_CODE(
data->registry_data.stable_pstate_sclk_dpm_percentage >= 1 &&
data->registry_data.stable_pstate_sclk_dpm_percentage <= 100,
Expand Down

0 comments on commit 0d1da3c

Please sign in to comment.