Commit 08e9ebc7 authored by Bas Nieuwenhuizen's avatar Bas Nieuwenhuizen Committed by Alex Deucher

drm/amd/pm: Handle non-terminated overdrive commands.

The incoming strings might not be terminated by a newline
or a 0.

(found while testing a program that just wrote the string
 itself, causing a crash)

Cc: stable@vger.kernel.org
Fixes: e3933f26 ("drm/amd/pp: Add edit/commit/show OD clock/voltage support in sysfs")
Signed-off-by: default avatarBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 9248462d
...@@ -761,7 +761,7 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev, ...@@ -761,7 +761,7 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,
if (adev->in_suspend && !adev->in_runpm) if (adev->in_suspend && !adev->in_runpm)
return -EPERM; return -EPERM;
if (count > 127) if (count > 127 || count == 0)
return -EINVAL; return -EINVAL;
if (*buf == 's') if (*buf == 's')
...@@ -781,7 +781,8 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev, ...@@ -781,7 +781,8 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,
else else
return -EINVAL; return -EINVAL;
memcpy(buf_cpy, buf, count+1); memcpy(buf_cpy, buf, count);
buf_cpy[count] = 0;
tmp_str = buf_cpy; tmp_str = buf_cpy;
...@@ -798,6 +799,9 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev, ...@@ -798,6 +799,9 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,
return -EINVAL; return -EINVAL;
parameter_size++; parameter_size++;
if (!tmp_str)
break;
while (isspace(*tmp_str)) while (isspace(*tmp_str))
tmp_str++; tmp_str++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment