Skip to content

Commit 08e9ebc

Browse files
BNieuwenhuizenalexdeucher
authored andcommitted
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: [email protected] Fixes: e3933f2 ("drm/amd/pp: Add edit/commit/show OD clock/voltage support in sysfs") Signed-off-by: Bas Nieuwenhuizen <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 9248462 commit 08e9ebc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/gpu/drm/amd/pm/amdgpu_pm.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,
761761
if (adev->in_suspend && !adev->in_runpm)
762762
return -EPERM;
763763

764-
if (count > 127)
764+
if (count > 127 || count == 0)
765765
return -EINVAL;
766766

767767
if (*buf == 's')
@@ -781,7 +781,8 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,
781781
else
782782
return -EINVAL;
783783

784-
memcpy(buf_cpy, buf, count+1);
784+
memcpy(buf_cpy, buf, count);
785+
buf_cpy[count] = 0;
785786

786787
tmp_str = buf_cpy;
787788

@@ -798,6 +799,9 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,
798799
return -EINVAL;
799800
parameter_size++;
800801

802+
if (!tmp_str)
803+
break;
804+
801805
while (isspace(*tmp_str))
802806
tmp_str++;
803807
}

0 commit comments

Comments
 (0)