drm/amdgpu: Fix uninitialized variable warning in amdgpu_afmt_acr
Subsystems (2)
PATCH 1/3 drm/amdgpu: Fix uninitialized variable warning in amdgpu_afmt_acr
Assign value to clock to fix the warning below:
"Using uninitialized value res. Field res.clock is uninitialized"
--- drivers/gpu/drm/amd/amdgpu/amdgpu_afmt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_afmt.c +2 -1
@@ -87,7 +87,7 @@ static void amdgpu_afmt_calc_cts(uint32_t clock, int *CTS, int *N, int freq)struct amdgpu_afmt_acr amdgpu_afmt_acr (uint32_t clock) { -struct amdgpu_afmt_acr res; +struct amdgpu_afmt_acr res = {0 };u8 i;/* Precalculated values for common clocks */
@@ -100,6 +100,7 @@ struct amdgpu_afmt_acr amdgpu_afmt_acr(uint32_t clock)amdgpu_afmt_calc_cts (clock, &res.cts_32khz, &res.n_32khz,32000 );amdgpu_afmt_calc_cts (clock, &res.cts_44_1khz, &res.n_44_1khz,44100 );amdgpu_afmt_calc_cts (clock, &res.cts_48khz, &res.n_48khz,48000 ); + res.clock = clock;return res; }
Signature · 1 line
2.34.1
PATCH 2/3 drm/amdgpu: Initialize timestamp for some legacy SOCs
Initialize the interrupt timestamp for some legacy SOCs to fix the coverity issue "Uninitialized scalar variable"
--- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +8 -0
@@ -445,6 +445,14 @@ void amdgpu_irq_dispatch(struct amdgpu_device *adev, entry.ih = ih; entry.iv_entry = (const uint32_t *)&ih->ring[ring_index]; + +/* +* timestamp is not supported on some legacy SOCs (cik, cz, iceland, +* si and tonga), so initialize timestamp and timestamp_src to 0 +*/ + entry.timestamp =0 ; + entry.timestamp_src =0 ; +amdgpu_ih_decode_iv (adev, &entry);trace_amdgpu_iv (ih - &adev->irq.ih, &entry);
Signature · 1 line
2.34.1
Re: [PATCH 2/3] drm/amdgpu: Initialize timestamp for some legacy SOCs
Am 24.04.24 um 12:03 schrieb Ma Jun:
Quoted 5 lines
Initialize the interrupt timestamp for some legacy SOCs to fix the coverity issue "Uninitialized scalar variable"
Signed-off-by Ma Jun <[email protected]>Suggested-by Christian König <[email protected]>
Quoted 23 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +8
-0@@ -445,6 +445,14 @@ void amdgpu_irq_dispatch(struct amdgpu_device *adev, entry.ih = ih; entry.iv_entry = (const uint32_t *)&ih->ring[ring_index]; + +/* +* timestamp is not supported on some legacy SOCs (cik, cz, iceland, +* si and tonga), so initialize timestamp and timestamp_src to 0 +*/ + entry.timestamp =0 ; + entry.timestamp_src =0 ; +amdgpu_ih_decode_iv (adev, &entry);trace_amdgpu_iv (ih - &adev->irq.ih, &entry);
PATCH 3/3 drm/amdgpu: Fix the uninitialized variable warning
In reply to Ma JunInitialize the phy_id to 0 to fix the warning of
"Using uninitialized value phy_id"
--- drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c +1 -1
@@ -95,7 +95,7 @@ static ssize_t amdgpu_securedisplay_debugfs_write(struct file *f, const char __ustruct psp_context *psp = &adev->psp;struct ta_securedisplay_cmd *securedisplay_cmd;struct drm_device *dev =adev_to_drm (adev); -uint32_t phy_id; +uint32_t phy_id =0 ;uint32_t op;char str[64 ];int ret;
Signature · 1 line
2.34.1
Deucher, Alexander
maintainerRE: [PATCH 3/3] drm/amdgpu: Fix the uninitialized variable warning
[AMD Official Use Only - General]
Quoted 26 lines
-----Original Message-----
From: Ma, Jun <[email protected]>
Sent: Wednesday, April 24, 2024 6:04 AM
To: [email protected]; Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]>
Cc: Ma, Jun <[email protected]>
Subject: [PATCH 3/3] drm/amdgpu: Fix the uninitialized variable warningInitialize the
phy_idto 0 to fix the warning of "Using uninitialized valuephy_id"Signed-off-by Ma Jun <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c +0
-0@@ -95,7 +95,7 @@ static ssize_tamdgpu_securedisplay_debugfs_write(struct file *f, const char
__ustruct psp_context *psp = &adev->psp; struct ta_securedisplay_cmd *securedisplay_cmd; struct drm_device *dev = adev_to_drm(adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c static ssize_t amdgpu_securedisplay_debugfs_write(struct file *f, const char __u · line 98
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c +1
-1-uint32_t phy_id; +uint32_t phy_id =0 ;
Would be better to return an error in case 2: below if size < 3. Otherwise we are just blindly using 0 for phy id.
Alex
Quoted 5 lines
uint32_t op; char str[64]; int ret;--
2.34.1
Deucher, Alexander
maintainer[AMD Official Use Only - General]
Quoted 24 lines
-----Original Message-----
From: Ma, Jun <[email protected]>
Sent: Wednesday, April 24, 2024 6:04 AM
To: [email protected]; Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]>
Cc: Ma, Jun <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: Fix uninitialized variable warning inamdgpu_afmt_acrAssign value to clock to fix the warning below:
"Using uninitialized value res. Field res.clock is uninitialized"Signed-off-by Ma Jun <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_afmt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_afmt.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_afmt.c static void amdgpu_afmt_calc_cts(uint32_t clock, int · line 90
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_afmt.c +1
-1@@ -87,7 +87,7 @@ static void amdgpu_afmt_calc_cts(uint32_t clock, int *CTS, int *N, int freq)struct amdgpu_afmt_acr amdgpu_afmt_acr (uint32_t clock) { -struct amdgpu_afmt_acr res; +struct amdgpu_afmt_acr res = {0 };
I think you can drop this hunk since all of the fields are initialized below.
Alex
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_afmt.c +0
-0u8 i; /* Precalculated values for common clocks */ @@ -100,6 +100,7 @@struct
amdgpu_afmt_acramdgpu_afmt_acr(uint32_t clock)amdgpu_afmt_calc_cts(clock, &res.cts_32khz, &res.n_32khz, 32000); amdgpu_afmt_calc_cts(clock, &res.cts_44_1khz, &res.n_44_1khz, 44100); amdgpu_afmt_calc_cts(clock, &res.cts_48khz, &res.n_48khz, 48000);+ res.clock = clock;
return res;}
--
2.34.1