[PATCH] drm/amdgpu: Fix uninitialized return value

Christian König ckoenig.leichtzumerken at gmail.com
Mon Nov 27 18:46:01 UTC 2023


Am 27.11.23 um 19:29 schrieb Lijo Lazar:
> The return value is uniinitialized if ras context is NULL.
>
> Fixes: 0f4c8faa043c (drm/amdgpu: Move mca debug mode decision to ras)
>
> Signed-off-by: Lijo Lazar <lijo.lazar at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> index 1a8668a63e67..f6b47ebce9d6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> @@ -3410,7 +3410,7 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device *adev)
>   int amdgpu_ras_set_mca_debug_mode(struct amdgpu_device *adev, bool enable)
>   {
>   	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
> -	int ret;
> +	int ret = 0;

That's usually considered very bad coding style and complained about by 
automated checkers.

Instead explicitly set the return value in the code paths not actually 
setting it.

Regards,
Christian.

>   
>   	if (con) {
>   		ret = amdgpu_mca_smu_set_debug_mode(adev, enable);



More information about the amd-gfx mailing list