drm/amd/display: Initialize return value in dm_cache_state()
Subsystems (3)
PATCH RESEND 1/1 drm/amd/display: Initialize return value in dm_cache_state()
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.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
@@ -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)) {
Signature · 1 line
2.43.0
Quoted 5 lines · Eslam Khafagy
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.
Quoted 19 lines
Signed-off-by Eslam Khafagy <[email protected]>--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -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)) {
Quoted 6 lines · Mario Limonciello
Quoted 3 lines · Eslam Khafagy
Initialize the return variable "r" to 0 in
dm_cache_state()to fix a potential use of uninitialized variable warning.
Quoted 6 lines
Quoted 2 lines
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 returnERR_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.
Quoted 19 lines
Quoted 18 lines
Signed-off-by Eslam Khafagy <[email protected]>---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -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)) {