• Arnd Bergmann's avatar
    drm/amd/powerplay: vega20: fix uninitialized variable use · de48ebdd
    Arnd Bergmann authored
    If smu_get_current_rpm() fails, we can't use the output,
    as that may be uninitialized:
    
    drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:3023:8: error: variable 'current_rpm' is used uninitialized whenever '?:' condition is false [-Werror,-Wsometimes-uninitialized]
            ret = smu_get_current_rpm(smu, &current_rpm);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/gpu/drm/amd/amdgpu/../powerplay/inc/amdgpu_smu.h:735:3: note: expanded from macro 'smu_get_current_rpm'
            ((smu)->funcs->get_current_rpm ? (smu)->funcs->get_current_rpm((smu), (speed)) : 0)
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:3024:12: note: uninitialized use occurs here
            percent = current_rpm * 100 / pptable->FanMaximumRpm;
                      ^~~~~~~~~~~
    drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:3023:8: note: remove the '?:' if its condition is always true
            ret = smu_get_current_rpm(smu, &current_rpm);
                  ^
    drivers/gpu/drm/amd/amdgpu/../powerplay/inc/amdgpu_smu.h:735:3: note: expanded from macro 'smu_get_current_rpm'
            ((smu)->funcs->get_current_rpm ? (smu)->funcs->get_current_rpm((smu), (speed)) : 0)
             ^
    drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:3020:22: note: initialize the variable 'current_rpm' to silence this warning
            uint32_t current_rpm;
    
    Propagate the error code in that case.
    
    Fixes: ee0db820 ("drm/amd/powerplay: move PPTable_t uses into asic level")
    Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
    Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
    de48ebdd
vega20_ppt.c 102 KB