* [PATCH RESEND] drm/amd/display: Initialize return value in dm_cache_state()
@ 2025-10-07 22:45 Eslam Khafagy
2025-10-08 2:15 ` Mario Limonciello
0 siblings, 1 reply; 3+ messages in thread
From: Eslam Khafagy @ 2025-10-07 22:45 UTC (permalink / raw)
To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, David Airlie, Simona Vetter,
Mario Limonciello, Alex Hung, Wayne Lin, Aurabindo Pillai,
Tom Chung, Dominik Kaszewski, Yilin Chen,
open list:AMD DISPLAY CORE, open list:DRM DRIVERS, open list
Cc: eslam.medhat1993
Initialize the return variable "r" to 0 in dm_cache_state() to fix
a potential use of uninitialized variable warning.
The return value for this function might not be a PTR_ERR, in casse if
condition fails. In that case we ensure predictable reutrn.
Signed-off-by: Eslam Khafagy <eslam.medhat1993@gmail.com>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 8e1622bf7a42..6b4f3eb9ce48 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3115,7 +3115,7 @@ static void hpd_rx_irq_work_suspend(struct amdgpu_display_manager *dm)
static int dm_cache_state(struct amdgpu_device *adev)
{
- int r;
+ int r = 0;
adev->dm.cached_state = drm_atomic_helper_suspend(adev_to_drm(adev));
if (IS_ERR(adev->dm.cached_state)) {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND] drm/amd/display: Initialize return value in dm_cache_state()
2025-10-07 22:45 [PATCH RESEND] drm/amd/display: Initialize return value in dm_cache_state() Eslam Khafagy
@ 2025-10-08 2:15 ` Mario Limonciello
2025-10-08 22:00 ` Eslam Khafagy
0 siblings, 1 reply; 3+ messages in thread
From: Mario Limonciello @ 2025-10-08 2:15 UTC (permalink / raw)
To: Eslam Khafagy, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, David Airlie, Simona Vetter,
Alex Hung, Wayne Lin, Aurabindo Pillai, Tom Chung,
Dominik Kaszewski, Yilin Chen, open list:AMD DISPLAY CORE,
open list:DRM DRIVERS, open list
On 10/7/2025 5:45 PM, Eslam Khafagy wrote:
> Initialize the return variable "r" to 0 in dm_cache_state() to fix
> a potential use of uninitialized variable warning.
>
> The return value for this function might not be a PTR_ERR, in casse if
> condition fails. In that case we ensure predictable reutrn.
Can you walk me through your thought process? I looked at all possible
returns for drm_atomic_helper_suspend() and they all return ERR_PTR() or
a state.
So I don't see how the IS_ERR() clause could have a problem.
>
> Signed-off-by: Eslam Khafagy <eslam.medhat1993@gmail.com>
> ---
> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 8e1622bf7a42..6b4f3eb9ce48 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -3115,7 +3115,7 @@ static void hpd_rx_irq_work_suspend(struct amdgpu_display_manager *dm)
>
> static int dm_cache_state(struct amdgpu_device *adev)
> {
> - int r;
> + int r = 0;
>
> adev->dm.cached_state = drm_atomic_helper_suspend(adev_to_drm(adev));
> if (IS_ERR(adev->dm.cached_state)) {
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND] drm/amd/display: Initialize return value in dm_cache_state()
2025-10-08 2:15 ` Mario Limonciello
@ 2025-10-08 22:00 ` Eslam Khafagy
0 siblings, 0 replies; 3+ messages in thread
From: Eslam Khafagy @ 2025-10-08 22:00 UTC (permalink / raw)
To: Mario Limonciello, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, David Airlie, Simona Vetter,
Alex Hung, Wayne Lin, Aurabindo Pillai, Tom Chung,
Dominik Kaszewski, Yilin Chen, open list:AMD DISPLAY CORE,
open list:DRM DRIVERS, open list
On 10/8/25 05:15, Mario Limonciello wrote:
>
>
> On 10/7/2025 5:45 PM, Eslam Khafagy wrote:
>> Initialize the return variable "r" to 0 in dm_cache_state() to fix
>> a potential use of uninitialized variable warning.
>>
>> The return value for this function might not be a PTR_ERR, in casse if
>> condition fails. In that case we ensure predictable reutrn.
>
> Can you walk me through your thought process? I looked at all
> possible returns for drm_atomic_helper_suspend() and they all return
> ERR_PTR() or a state.
>
> So I don't see how the IS_ERR() clause could have a problem.
Hello ,
Thank you for the response. Initially i was working on warnings via
coverity scan.
Initially my thinking was just by following the sequence of
dm_cache_state you can see that there was a potential issue if
drm_atomic_helper_suspend returned a non valid pointer that is not PTR_ERR.
But having a second look after your response, indeed it shouldn't be the
case. so please feel free to drop this patch.
>>
>> Signed-off-by: Eslam Khafagy <eslam.medhat1993@gmail.com>
>> ---
>> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> index 8e1622bf7a42..6b4f3eb9ce48 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> @@ -3115,7 +3115,7 @@ static void hpd_rx_irq_work_suspend(struct
>> amdgpu_display_manager *dm)
>> static int dm_cache_state(struct amdgpu_device *adev)
>> {
>> - int r;
>> + int r = 0;
>> adev->dm.cached_state =
>> drm_atomic_helper_suspend(adev_to_drm(adev));
>> if (IS_ERR(adev->dm.cached_state)) {
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-09 7:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-07 22:45 [PATCH RESEND] drm/amd/display: Initialize return value in dm_cache_state() Eslam Khafagy
2025-10-08 2:15 ` Mario Limonciello
2025-10-08 22:00 ` Eslam Khafagy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox