From: jsg Date: Thu, 30 Nov 2023 02:44:33 +0000 (+0000) Subject: drm/amd/pm: Handle non-terminated overdrive commands. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=385c2c2737fcd800c0fa946285df56450191117c;p=openbsd drm/amd/pm: Handle non-terminated overdrive commands. From Bas Nieuwenhuizen e973f40de16125f3f85a07db68a2ad4a0aeb42c2 in linux-6.1.y/6.1.64 08e9ebc75b5bcfec9d226f9e16bab2ab7b25a39a in mainline linux --- 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++; }