drm/amd/pm: Handle non-terminated overdrive commands.
commit 08e9ebc75b5bcfec9d226f9e16bab2ab7b25a39a upstream.
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: e3933f26b6
("drm/amd/pp: Add edit/commit/show OD clock/voltage support in sysfs")
Signed-off-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
7dc933b4b4
commit
dfa8e63ca5
@@ -776,7 +776,7 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,
|
|||||||
if (amdgpu_in_reset(adev))
|
if (amdgpu_in_reset(adev))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
if (count > 127)
|
if (count > 127 || count == 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (*buf == 's')
|
if (*buf == 's')
|
||||||
@@ -792,7 +792,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;
|
||||||
|
|
||||||
@@ -807,6 +808,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++;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user