[PATCH] drm/amdgpu: Fail when setting negative DPM levels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



kstrtol can handle negative values, which is unchecked here. While
setting a negative value will result in the mask being 1<<0xffffffff ,
which the SMU will ignore because it's out of long bits, return an
error instead of silently failing.

Signed-off-by: Kent Russell <kent.russell at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 9e73cbc..145ef62 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -476,7 +476,7 @@ static ssize_t amdgpu_set_pp_dpm_sclk(struct device *dev,
 		sub_str[1] = '\0';
 		ret = kstrtol(sub_str, 0, &level);
 
-		if (ret) {
+		if (ret || level < 0) {
 			count = -EINVAL;
 			goto fail;
 		}
@@ -522,7 +522,7 @@ static ssize_t amdgpu_set_pp_dpm_mclk(struct device *dev,
 		sub_str[1] = '\0';
 		ret = kstrtol(sub_str, 0, &level);
 
-		if (ret) {
+		if (ret || level < 0) {
 			count = -EINVAL;
 			goto fail;
 		}
@@ -567,7 +567,7 @@ static ssize_t amdgpu_set_pp_dpm_pcie(struct device *dev,
 		sub_str[1] = '\0';
 		ret = kstrtol(sub_str, 0, &level);
 
-		if (ret) {
+		if (ret || level < 0) {
 			count = -EINVAL;
 			goto fail;
 		}
-- 
2.7.4



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux