diff options
| author | Bas Nieuwenhuizen <[email protected]> | 2023-10-17 16:01:35 +0200 | 
|---|---|---|
| committer | Alex Deucher <[email protected]> | 2023-10-20 15:11:26 -0400 | 
| commit | 08e9ebc75b5bcfec9d226f9e16bab2ab7b25a39a (patch) | |
| tree | aed9f199a0b5c02c76247f175364888b177d0016 /drivers/gpu/drm/amd/pm/amdgpu_pm.c | |
| parent | 9248462d7e0862883df6741ec0e1bb41c3698b22 (diff) | |
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: e3933f26b657 ("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]>
Diffstat (limited to 'drivers/gpu/drm/amd/pm/amdgpu_pm.c')
| -rw-r--r-- | drivers/gpu/drm/amd/pm/amdgpu_pm.c | 8 | 
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c index d76c3abf406f..358bb5e485f2 100644 --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c @@ -761,7 +761,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') @@ -781,7 +781,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; @@ -798,6 +799,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++;  	}  |