This is a note to let you know that I've just added the patch titled drm/amd/pm: Handle non-terminated overdrive commands. to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: drm-amd-pm-handle-non-terminated-overdrive-commands.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 08e9ebc75b5bcfec9d226f9e16bab2ab7b25a39a Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen <bas@xxxxxxxxxxxxxxxxxxx> Date: Tue, 17 Oct 2023 16:01:35 +0200 Subject: drm/amd/pm: Handle non-terminated overdrive commands. From: Bas Nieuwenhuizen <bas@xxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxx Fixes: e3933f26b657 ("drm/amd/pp: Add edit/commit/show OD clock/voltage support in sysfs") Signed-off-by: Bas Nieuwenhuizen <bas@xxxxxxxxxxxxxxxxxxx> Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c @@ -758,7 +758,7 @@ static ssize_t amdgpu_set_pp_od_clk_volt if (adev->in_suspend && !adev->in_runpm) return -EPERM; - if (count > 127) + if (count > 127 || count == 0) return -EINVAL; if (*buf == 's') @@ -778,7 +778,8 @@ static ssize_t amdgpu_set_pp_od_clk_volt else return -EINVAL; - memcpy(buf_cpy, buf, count+1); + memcpy(buf_cpy, buf, count); + buf_cpy[count] = 0; tmp_str = buf_cpy; @@ -795,6 +796,9 @@ static ssize_t amdgpu_set_pp_od_clk_volt return -EINVAL; parameter_size++; + if (!tmp_str) + break; + while (isspace(*tmp_str)) tmp_str++; } Patches currently in stable-queue which might be from bas@xxxxxxxxxxxxxxxxxxx are queue-6.1/drm-amd-pm-handle-non-terminated-overdrive-commands.patch