[PATCH] drm/amd/amdgpu: Fix an uninitialized variable

Christian König christian.koenig at amd.com
Mon Jan 9 09:03:34 UTC 2023


Am 09.01.23 um 09:29 schrieb Srinivasan Shanmugam:
>    CC      drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.o
> drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c:217:71: error: variable 'i' is uninitialized when used here [-Werror,-Wuninitialized]
>                  snprintf(fw_name, sizeof(fw_name), "amdgpu/%s%d.bin", ucode_prefix, i);
>                                                                                      ^
> drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c:207:16: note: initialize the variable 'i' to silence this warning
>          int err = 0, i;
>                        ^
>                         = 0
>
> Initialize the variable 'i'.

Big NAK to this. As far as I can see this just silences the compiler 
warning, but doesn't fix the underlying bug.

Please initialize the variable where it is necessary.

Regards,
Christian.

>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
> index 0e1e2521fe25a..64f2b855a378a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
> @@ -204,7 +204,7 @@ int amdgpu_sdma_init_microcode(struct amdgpu_device *adev,
>   {
>   	struct amdgpu_firmware_info *info = NULL;
>   	const struct common_firmware_header *header = NULL;
> -	int err = 0, i;
> +	int err = 0, i = 0;
>   	const struct sdma_firmware_header_v2_0 *sdma_hdr;
>   	uint16_t version_major;
>   	char ucode_prefix[30];



More information about the amd-gfx mailing list