diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-11-30 02:44:34 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-11-30 02:44:34 +0000 |
commit | bb223c33872cd2f4720acf1ae201c2929c3994c6 (patch) | |
tree | dc58fd6073b7f8993cd4cf2f8e5578175b31c254 /sys | |
parent | c31d476240e02d82090e9cbef2971e9207063954 (diff) |
drm/amd/pm: Handle non-terminated overdrive commands.
From Bas Nieuwenhuizen
e973f40de16125f3f85a07db68a2ad4a0aeb42c2 in linux-6.1.y/6.1.64
08e9ebc75b5bcfec9d226f9e16bab2ab7b25a39a in mainline linux
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/drm/amd/pm/amdgpu_pm.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/dev/pci/drm/amd/pm/amdgpu_pm.c b/sys/dev/pci/drm/amd/pm/amdgpu_pm.c index 5e27a5ab624..cb2fa34fb11 100644 --- a/sys/dev/pci/drm/amd/pm/amdgpu_pm.c +++ b/sys/dev/pci/drm/amd/pm/amdgpu_pm.c @@ -760,7 +760,7 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - if (count > 127) + if (count > 127 || count == 0) return -EINVAL; if (*buf == 's') @@ -780,7 +780,8 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev, else return -EINVAL; - memcpy(buf_cpy, buf, count+1); + memcpy(buf_cpy, buf, count); + buf_cpy[count] = 0; tmp_str = buf_cpy; @@ -797,6 +798,9 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev, return -EINVAL; parameter_size++; + if (!tmp_str) + break; + while (isspace(*tmp_str)) tmp_str++; } |