Skip to contentSkip to conversation

swsmu/amdgpu_smu: Fix the wrong if-condition

PATCH Applied Yu Songping 3 participants 3 messages Nov 24, 2022 – Nov 25, 2022

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

PATCH 1/1 swsmu/amdgpu_smu: Fix the wrong if-condition

The logical operator '&&' will make smu->ppt_funcs->set_gfx_power_up_by_imu segment fault when smu->ppt_funcs is NULL.

---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1 -1
index b880f4d7d67e..1cb728b0b7ee 100644
@@ -161,7 +161,7 @@ int smu_get_dpm_freq_range(struct smu_context *smu,
 
 int smu_set_gfx_power_up_by_imu(struct smu_context *smu)
 {
-	if (!smu->ppt_funcs && !smu->ppt_funcs->set_gfx_power_up_by_imu)
+	if (!smu->ppt_funcs || !smu->ppt_funcs->set_gfx_power_up_by_imu)
 		return -EOPNOTSUPP;
 
 	return smu->ppt_funcs->set_gfx_power_up_by_imu(smu);
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - General]

Quoted 37 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yu Songping
Sent: Thursday, November 24, 2022 9:53 AM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: [PATCH] swsmu/amdgpu_smu: Fix the wrong if-condition

The logical operator '&&' will make smu->ppt_funcs->set_gfx_power_up_by_imu segment fault when ppt_funcs is
smu->NULL.

---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1 -1
index b880f4d7d67e..1cb728b0b7ee 100644
@@ -161,7 +161,7 @@ int smu_get_dpm_freq_range(struct smu_context
 *smu,
 
 int smu_set_gfx_power_up_by_imu(struct smu_context *smu)  {
-	if (!smu->ppt_funcs && !smu->ppt_funcs-
 >set_gfx_power_up_by_imu)
+	if (!smu->ppt_funcs || !smu->ppt_funcs-
 >set_gfx_power_up_by_imu)
 		return -EOPNOTSUPP;

return smu->ppt_funcs->set_gfx_power_up_by_imu(smu);
--
2.17.1

Applied
#2 lore raw

Applied!

Thanks,
Luben

Quoted 41 lines · Evan

[AMD Official Use Only - General]

Quoted 37 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yu Songping
Sent: Thursday, November 24, 2022 9:53 AM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: [PATCH] swsmu/amdgpu_smu: Fix the wrong if-condition

The logical operator '&&' will make smu->ppt_funcs->set_gfx_power_up_by_imu segment fault when ppt_funcs is
smu->NULL.

---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1 -1
index b880f4d7d67e..1cb728b0b7ee 100644
@@ -161,7 +161,7 @@ int smu_get_dpm_freq_range(struct smu_context
 *smu,
 
 int smu_set_gfx_power_up_by_imu(struct smu_context *smu)  {
-     if (!smu->ppt_funcs && !smu->ppt_funcs-
 > set_gfx_power_up_by_imu)
+     if (!smu->ppt_funcs || !smu->ppt_funcs-
 > set_gfx_power_up_by_imu)
              return -EOPNOTSUPP;
      return smu->ppt_funcs->set_gfx_power_up_by_imu(smu);

--
2.17.1