drm/amdgpu: Fail when setting negative DPM levels
Subsystems (2)
PATCH 1/1 drm/amdgpu: Fail when setting negative DPM levels
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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +3 -3
@@ -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; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1520012334-24036-1-git-send-email-kent.russell-5C7GfCeVMHo@public.gmane.org
Deucher, Alexander
Reviewed-by Alex DeucherQuoted 8 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Kent Russell
Sent: Friday, March 2, 2018 12:39 PM
To: [email protected]
Cc: Russell, Kent <[email protected]>
Subject: [PATCH] drm/amdgpu: Fail when setting negative DPM levels
Quoted 5 lines
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 <[email protected]>
Quoted 42 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-1@@ -476,7 +476,7 @@ static ssize_t amdgpu_set_pp_dpm_sclk(structdevice *dev, sub_str[1 ] ='\0' ; ret =kstrtol (sub_str,0 , &level); -if (ret) { +if (ret || level <0 ) { count = -EINVAL ; goto fail;drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-1}@@ -522,7 +522,7 @@ static ssize_t amdgpu_set_pp_dpm_mclk(structdevice *dev, sub_str[1 ] ='\0' ; ret =kstrtol (sub_str,0 , &level); -if (ret) { +if (ret || level <0 ) { count = -EINVAL ; goto fail;drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-1}@@ -567,7 +567,7 @@ static ssize_t amdgpu_set_pp_dpm_pcie(structdevice *dev, sub_str[1 ] ='\0' ; ret =kstrtol (sub_str,0 , &level); -if (ret) { +if (ret || level <0 ) { count = -EINVAL ; goto fail;}
--
2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx