Skip to contentSkip to conversation

drm/amd/pm: initialize variable

PATCH Applied [email protected] 2 participants 2 messages Apr 30, 2021 – May 4, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/pm: initialize variable

From: Tom Rix <[email protected]>

Static analysis reports this problem

amdgpu_pm.c:478:16: warning: The right operand of '<' is a garbage value

  for (i = 0; i < data.nums; i++) {
                ^ ~~~~~~~~~

In some cases data is not set. Initialize to 0 and flag not setting data as an error with the existing check.

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -1
index 4e459ef632ef..9a54066ec0af 100644
@@ -451,7 +451,7 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,
 	struct drm_device *ddev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = drm_to_adev(ddev);
 	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
-	struct pp_states_info data;
+	struct pp_states_info data = {0};
 	enum amd_pm_state_type pm = 0;
 	int i = 0, ret = 0;
 
Signature · 6 lines
2.26.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Applied
#1 lore raw
Quoted 5 lines · On Fri, Apr 30, 2021 at 2:05 PM <[email protected]> wrote:

From: Tom Rix <[email protected]>

Static analysis reports this problem

Quoted 8 lines

amdgpu_pm.c:478:16: warning: The right operand of '<' is a garbage value

  for (i = 0; i < data.nums; i++) {
                ^ ~~~~~~~~~

In some cases data is not set. Initialize to 0 and flag not setting data as an error with the existing check.

Applied. Thanks!

Alex

Quoted 20 lines
---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -2
index 4e459ef632ef..9a54066ec0af 100644
@@ -451,7 +451,7 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,
        struct drm_device *ddev = dev_get_drvdata(dev);
        struct amdgpu_device *adev = drm_to_adev(ddev);
        const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
-       struct pp_states_info data;
+       struct pp_states_info data = {0};
        enum amd_pm_state_type pm = 0;
        int i = 0, ret = 0;
 
--

2.26.3

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel