OSDN Git Service

drm/amd/pm: initialize variable
authorTom Rix <trix@redhat.com>
Fri, 30 Apr 2021 17:16:54 +0000 (10:16 -0700)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 10 May 2021 22:06:45 +0000 (18:06 -0400)
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.

Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/amdgpu_pm.c

index e054249..f11cecd 100644 (file)
@@ -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;