drm/amdgpu: Fail when setting negative DPM levels v2
Subsystems (2)
PATCH 1/1 drm/amdgpu: Fail when setting negative DPM levels v2
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.
v2 Add similar check for sclk_od and mclk_od
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +5 -5
@@ -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; }
@@ -606,7 +606,7 @@ static ssize_t amdgpu_set_pp_sclk_od(struct device *dev, ret =kstrtol (buf,0 , &value); -if (ret) { +if (ret || value <0 ) { count = -EINVAL ; goto fail; }
@@ -650,7 +650,7 @@ static ssize_t amdgpu_set_pp_mclk_od(struct device *dev, ret =kstrtol (buf,0 , &value); -if (ret) { +if (ret || value <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): 1520013187-24300-1-git-send-email-kent.russell-5C7GfCeVMHo@public.gmane.org
Eric Huang
Reviewed-byQuoted 53 lines · Kent Russell
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.
v2 Add similar check for
sclk_odandmclk_odSigned-off-by Kent Russell <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +4
-4@@ -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; }@@ -606,7 +606,7 @@ static ssize_t amdgpu_set_pp_sclk_od(struct device *dev, ret =kstrtol (buf,0 , &value); -if (ret) { +if (ret || value <0 ) { count = -EINVAL ; goto fail; }
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_set_pp_mclk_od(struct device *dev, · line 656
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-1@@ -650,7 +650,7 @@ static ssize_t amdgpu_set_pp_mclk_od(struct device *dev, ret =kstrtol (buf,0 , &value); -if (ret) { +if (ret || value <0 ) { count = -EINVAL ; goto fail; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
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:53 PM
To: [email protected]
Cc: Russell, Kent <[email protected]>
Subject: [PATCH] drm/amdgpu: Fail when setting negative DPM levels v2
Quoted 7 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.
v2 Add similar check for
sclk_odandmclk_odSigned-off-by Kent Russell <[email protected]>
Quoted 62 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 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;drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-1}@@ -606,7 +606,7 @@ static ssize_t amdgpu_set_pp_sclk_od(struct device *dev, ret =kstrtol (buf,0 , &value); -if (ret) { +if (ret || value <0 ) { count = -EINVAL ; goto fail;drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1
-1}@@ -650,7 +650,7 @@ static ssize_t amdgpu_set_pp_mclk_od(struct device *dev, ret =kstrtol (buf,0 , &value); -if (ret) { +if (ret || value <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