[PATCH 3/3] drm/amdgpu: Fix Uninitialized scalar variable warning

Christian König christian.koenig at amd.com
Mon Apr 22 11:25:07 UTC 2024


Am 22.04.24 um 11:49 schrieb Ma Jun:
> Initialize the variables which were not initialized
> to fix the coverity issue "Uninitialized scalar variable"

Feel free to add my Acked-by to the first two patches, but this here 
clearly doesn't looks like a good idea to me.

>
> Signed-off-by: Ma Jun <Jun.Ma2 at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 2 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 2 +-
>   3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
> index 7e6d09730e6d..7b28b6b8982b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
> @@ -437,7 +437,7 @@ void amdgpu_irq_dispatch(struct amdgpu_device *adev,
>   			 struct amdgpu_ih_ring *ih)
>   {
>   	u32 ring_index = ih->rptr >> 2;
> -	struct amdgpu_iv_entry entry;
> +	struct amdgpu_iv_entry entry = {0};

When this needs to be initialized there is clearly something wrong with 
the code. I would guess similar for the other two.

What exactly does coverity complains about?

Regards,
Christian.

>   	unsigned int client_id, src_id;
>   	struct amdgpu_irq_src *src;
>   	bool handled = false;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 924baf58e322..f0a63d084b4d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -1559,7 +1559,7 @@ static int amdgpu_debugfs_firmware_info_show(struct seq_file *m, void *unused)
>   {
>   	struct amdgpu_device *adev = m->private;
>   	struct drm_amdgpu_info_firmware fw_info;
> -	struct drm_amdgpu_query_fw query_fw;
> +	struct drm_amdgpu_query_fw query_fw = {0};
>   	struct atom_context *ctx = adev->mode_info.atom_context;
>   	uint8_t smu_program, smu_major, smu_minor, smu_debug;
>   	int ret, i;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
> index 2b99eed5ba19..41ac3319108b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
> @@ -120,7 +120,7 @@ static void __amdgpu_xcp_add_block(struct amdgpu_xcp_mgr *xcp_mgr, int xcp_id,
>   int amdgpu_xcp_init(struct amdgpu_xcp_mgr *xcp_mgr, int num_xcps, int mode)
>   {
>   	struct amdgpu_device *adev = xcp_mgr->adev;
> -	struct amdgpu_xcp_ip ip;
> +	struct amdgpu_xcp_ip ip = {0};
>   	uint8_t mem_id;
>   	int i, j, ret;
>   



More information about the amd-gfx mailing list