RE: [PATCH] drm/amdgpu: Fail when setting negative DPM levels v2
> -Original Message- > From: amd-gfx [mailto:amd-gfx-boun...@lists.freedesktop.org] On Behalf > Of Kent Russell > Sent: Friday, March 2, 2018 12:53 PM > To: amd-...@freedesktop.org > Cc: Russell, Kent> Subject: [PATCH] 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<<0x , 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 > > Signed-off-by: Kent Russell Reviewed-by: Alex Deucher > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 10 +- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c > index 9e73cbc..5bdb421 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, ); > > - 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, ); > > - 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, ); > > - 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, ); > > - 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, ); > > - if (ret) { > + if (ret || value < 0) { > count = -EINVAL; > goto fail; > } > -- > 2.7.4 > > ___ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH] drm/amdgpu: Fail when setting negative DPM levels
> -Original Message- > From: amd-gfx [mailto:amd-gfx-boun...@lists.freedesktop.org] On Behalf > Of Kent Russell > Sent: Friday, March 2, 2018 12:39 PM > To: amd-...@freedesktop.org > Cc: Russell, Kent> Subject: [PATCH] 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<<0x , which the SMU > will > ignore because it's out of long bits, return an error instead of silently > failing. > > Signed-off-by: Kent Russell Reviewed-by: Alex Deucher > --- > 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, ); > > - 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, ); > > - 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, ); > > - if (ret) { > + if (ret || level < 0) { > count = -EINVAL; > goto fail; > } > -- > 2.7.4 > > ___ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH] drm/amdgpu: Fail when setting negative DPM levels v2
Reviewed-by: Eric HuangOn 2018-03-02 12:53 PM, Kent Russell wrote: kstrtol can handle negative values, which is unchecked here. While setting a negative value will result in the mask being 1<<0x , 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 Signed-off-by: Kent Russell --- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c index 9e73cbc..5bdb421 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, ); - 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, ); - 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, ); - 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, ); - 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, ); - if (ret) { + if (ret || value < 0) { count = -EINVAL; goto fail; } ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx