[PATCH] drm/amdgpu: fix uninitialized scalar variable warning

Huang, Tim Tim.Huang at amd.com
Tue Apr 23 08:12:10 UTC 2024


[AMD Official Use Only - General]

-----Original Message-----
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Huang, Tim
Sent: Tuesday, April 23, 2024 4:01 PM
To: Koenig, Christian <Christian.Koenig at amd.com>; amd-gfx at lists.freedesktop.org
Cc: Deucher, Alexander <Alexander.Deucher at amd.com>
Subject: RE: [PATCH] drm/amdgpu: fix uninitialized scalar variable warning

[AMD Official Use Only - General]

[AMD Official Use Only - General]

Hi Christian,

-----Original Message-----
From: Koenig, Christian <Christian.Koenig at amd.com>
Sent: Tuesday, April 23, 2024 3:43 PM
To: Huang, Tim <Tim.Huang at amd.com>; amd-gfx at lists.freedesktop.org
Cc: Deucher, Alexander <Alexander.Deucher at amd.com>; Koenig, Christian <Christian.Koenig at amd.com>
Subject: Re: [PATCH] drm/amdgpu: fix uninitialized scalar variable warning

Am 23.04.24 um 08:28 schrieb Tim Huang:
> Clear warning that uses uninitialized value fw_size.

> In which case is the fw_size uninitialized and why setting it to zero helps in that case?

> It's a warning that reported by the Coverity scan.  When the switch case " switch (ucode_id) " got to default and Condition "adev->firmware.load_type == AMDGPU_FW_LOAD_PSP", taking true branch,  it reports " uses uninitialized value fw_size " by this line.
> "adev->firmware.fw_size += ALIGN(fw_size, PAGE_SIZE);“

> It may not happen if we call this function correctly, but it just clears the warning and looks harmless.

Hi Christian,

I think it more to fix this warning, maybe I need to print an error and just return when go to the default case of "switch (ucode_id)" , will send out a v2 patch. Thanks.

> Regards,
> Christian.

>
> Signed-off-by: Tim Huang <Tim.Huang at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> index d95555dc5485..6b8a58f501d3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> @@ -1084,7 +1084,7 @@ void amdgpu_gfx_cp_init_microcode(struct amdgpu_device *adev,
>       const struct gfx_firmware_header_v2_0 *cp_hdr_v2_0;
>       struct amdgpu_firmware_info *info = NULL;
>       const struct firmware *ucode_fw;
> -     unsigned int fw_size;
> +     unsigned int fw_size = 0;
>
>       switch (ucode_id) {
>       case AMDGPU_UCODE_ID_CP_PFP:



More information about the amd-gfx mailing list