Skip to contentSkip to conversation

drm/amd/pm: silence uninitialized variable warnings

PATCH Applied Dan Carpenter 3 participants 3 messages Aug 8 – Aug 10

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

PATCH 1/1 drm/amd/pm: silence uninitialized variable warnings

Smatch complains that:

drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu15/smu_v15_0_8_ppt.c:1964 smu_v15_0_8_set_performance_level() error: uninitialized symbol 'ret'.

In this line there is an "if (ret)" condition where "ret" is either zero or uninitialized. Initialize "ret" at the start of the function to avoid a potential uninitialized variable bug. But also delete the condition since it is never true.

Fixes 422b399b09c7 ("drm/amd/pm: Add od_edit_dpm_table support")
---
 drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c +1 -4
index 59fdd2319b66..c78e611d2a25 100644
@@ -1920,7 +1920,7 @@ static int smu_v15_0_8_set_performance_level(struct smu_context *smu,
 	struct smu_dpm_table *gfx_table = &dpm_context->dpm_tables.gfx_table;
 	struct smu_dpm_table *uclk_table = &dpm_context->dpm_tables.uclk_table;
 	struct smu_umd_pstate_table *pstate_table = &smu->pstate_table;
-	int ret;
+	int ret = 0;
 
 	switch (level) {
 	case AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM:
@@ -1961,9 +1961,6 @@ static int smu_v15_0_8_set_performance_level(struct smu_context *smu,
 				SMU_DPM_TABLE_MAX(uclk_table);
 		}
 
-		if (ret)
-			goto out;
-
 		smu_cmn_reset_custom_level(smu);
 
 		break;
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dan Carpenter

Smatch complains that:

drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu15/smu_v15_0_8_ppt.c:1964 smu_v15_0_8_set_performance_level() error: uninitialized symbol 'ret'.

Quoted 7 lines

In this line there is an "if (ret)" condition where "ret" is either zero or uninitialized. Initialize "ret" at the start of the function to avoid a potential uninitialized variable bug. But also delete the condition since it is never true.

Fixes 422b399b09c7 ("drm/amd/pm: Add od_edit_dpm_table support")

Thanks,
Lijo

Quoted 27 lines
---
  drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c +1 -4
index 59fdd2319b66..c78e611d2a25 100644
@@ -1920,7 +1920,7 @@ static int smu_v15_0_8_set_performance_level(struct smu_context *smu,
  	struct smu_dpm_table *gfx_table = &dpm_context->dpm_tables.gfx_table;
  	struct smu_dpm_table *uclk_table = &dpm_context->dpm_tables.uclk_table;
  	struct smu_umd_pstate_table *pstate_table = &smu->pstate_table;
-	int ret;
+	int ret = 0;
 
  	switch (level) {
  	case AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM:
@@ -1961,9 +1961,6 @@ static int smu_v15_0_8_set_performance_level(struct smu_context *smu,
  				SMU_DPM_TABLE_MAX(uclk_table);
  		}
 
-		if (ret)
-			goto out;
-
  		smu_cmn_reset_custom_level(smu);
 
  		break;
Applied
#2 lore raw

Applied. Thanks!

Alex

Quoted 50 lines · Lijo
Quoted 5 lines · Dan Carpenter

Smatch complains that:

drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu15/smu_v15_0_8_ppt.c:1964 smu_v15_0_8_set_performance_level() error: uninitialized symbol 'ret'.

Quoted 7 lines

In this line there is an "if (ret)" condition where "ret" is either zero or uninitialized. Initialize "ret" at the start of the function to avoid a potential uninitialized variable bug. But also delete the condition since it is never true.

Fixes 422b399b09c7 ("drm/amd/pm: Add od_edit_dpm_table support")

Thanks,
Lijo

Quoted 27 lines
---
  drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c +1 -4
index 59fdd2319b66..c78e611d2a25 100644
@@ -1920,7 +1920,7 @@ static int smu_v15_0_8_set_performance_level(struct smu_context *smu,
      struct smu_dpm_table *gfx_table = &dpm_context->dpm_tables.gfx_table;
      struct smu_dpm_table *uclk_table = &dpm_context->dpm_tables.uclk_table;
      struct smu_umd_pstate_table *pstate_table = &smu->pstate_table;
-     int ret;
+     int ret = 0;
 
      switch (level) {
      case AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM:
@@ -1961,9 +1961,6 @@ static int smu_v15_0_8_set_performance_level(struct smu_context *smu,
                              SMU_DPM_TABLE_MAX(uclk_table);
              }
 
-             if (ret)
-                     goto out;
-
              smu_cmn_reset_custom_level(smu);
 
              break;