Skip to contentSkip to conversation

drm/amd/pm: Add NULL check for power limit

PATCH In review Asad Kamal 2 participants 2 messages Nov 6, 2025

Subsystems (3)
lore
Share & tools
lore

Asad Kamal

author
#0 lore raw

PATCH v2 1/1 drm/amd/pm: Add NULL check for power limit

Add NULL check for smu power limit pointer

v2: Update error code on failure (Lijo)

---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3 -0
index 8b49fb86c77b..4a2c3ad0c38a 100644
@@ -2907,6 +2907,9 @@ int smu_get_power_limit(void *handle,
 	if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
 		return -EOPNOTSUPP;
 
+	if  (!limit)
+		return -EINVAL;
+
 	switch (pp_power_type) {
 	case PP_PWR_TYPE_SUSTAINED:
 		limit_type = SMU_DEFAULT_PPT_LIMIT;
Signature · 1 line
2.46.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 14 lines · Asad Kamal

Add NULL check for smu power limit pointer

v2: Update error code on failure (Lijo)

---
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -0
index 8b49fb86c77b..4a2c3ad0c38a 100644

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_get_power_limit(void *handle, · line 2912

Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3 -0
@@ -2907,6 +2907,9 @@ int smu_get_power_limit(void *handle,
  	if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
  		return -EOPNOTSUPP;
 
+	if  (!limit)
+		return -EINVAL;
+

Thanks,
Lijo

Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -0
  	switch (pp_power_type) {
  	case PP_PWR_TYPE_SUSTAINED:
  		limit_type = SMU_DEFAULT_PPT_LIMIT;