[PATCH] drm/amdgpu: Fix uninitialized variable in gfx_v9_4_3_cp_resume
Lazar, Lijo
lijo.lazar at amd.com
Fri May 19 05:59:15 UTC 2023
On 5/19/2023 11:21 AM, Srinivasan Shanmugam wrote:
> drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c:1925:6: error: variable 'r' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> if (amdgpu_xcp_query_partition_mode(adev->xcp_mgr,
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c:1931:6: note: uninitialized use occurs here
> if (r)
> ^
> drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c:1925:2: note: remove the 'if' if its condition is always true
> if (amdgpu_xcp_query_partition_mode(adev->xcp_mgr,
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c:1923:7: note: initialize the variable 'r' to silence this warning
> int r, i, num_xcc;
> ^
> = 0
> 1 error generated.
>
> Cc: Luben Tuikov <luben.tuikov at amd.com>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Cc: Christian König <christian.koenig at amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 18 ++++++++++--------
> 1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> index e5cfb3adb3b3..d4c9b156474e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> @@ -1920,22 +1920,24 @@ static int gfx_v9_4_3_xcc_cp_resume(struct amdgpu_device *adev, int xcc_id)
>
> static int gfx_v9_4_3_cp_resume(struct amdgpu_device *adev)
> {
> - int r, i, num_xcc;
> + int i, num_xcc;
>
> if (amdgpu_xcp_query_partition_mode(adev->xcp_mgr,
> AMDGPU_XCP_FL_NONE) ==
> AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE)
> - r = amdgpu_xcp_switch_partition_mode(adev->xcp_mgr,
> - amdgpu_user_partt_mode);
> + amdgpu_xcp_switch_partition_mode(adev->xcp_mgr,
> + amdgpu_user_partt_mode);
>
> - if (r)
> - return r;
> + if (amdgpu_xcp_switch_partition_mode(adev->xcp_mgr,
> + amdgpu_user_partt_mode))
> + return amdgpu_xcp_switch_partition_mode(adev->xcp_mgr,
> + amdgpu_user_partt_mode);
>
> num_xcc = NUM_XCC(adev->gfx.xcc_mask);
> for (i = 0; i < num_xcc; i++) {
> - r = gfx_v9_4_3_xcc_cp_resume(adev, i);
> - if (r)
> - return r;
> + gfx_v9_4_3_xcc_cp_resume(adev, i);
> + if (gfx_v9_4_3_xcc_cp_resume(adev, i))
> + return gfx_v9_4_3_xcc_cp_resume(adev, i);
> }
>
Are you realizing that you are calling the functions again which just
failed?
Init r = 0 to solve this and please avoid this type of fixes.
Thanks,
Lijo
> return 0;
More information about the amd-gfx
mailing list