diff options
author | 2020-07-29 11:00:56 +0000 | |
---|---|---|
committer | 2020-07-29 11:00:56 +0000 | |
commit | b954874d87b404ce3a8b85edf7ba474b2fa56332 (patch) | |
tree | f78b2076290a249c810de17b2c78cd58b051c3f7 | |
parent | drm/amdgpu: fix preemption unit test (diff) | |
download | wireguard-openbsd-b954874d87b404ce3a8b85edf7ba474b2fa56332.tar.xz wireguard-openbsd-b954874d87b404ce3a8b85edf7ba474b2fa56332.zip |
drm/amdgpu: Fix NULL dereference in dpm sysfs handlers
From Pawel Gronowski
f69137b000ffcfc726e8f3d567e0b69b34a49649 in linux 5.7.y/5.7.11
38e0c89a19fd13f28d2b4721035160a3e66e270b in mainline linux
-rw-r--r-- | sys/dev/pci/drm/amd/amdgpu/amdgpu_pm.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_pm.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_pm.c index 044ee6991b5..efe335ec8c7 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_pm.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_pm.c @@ -777,8 +777,7 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev, tmp_str++; while (isspace(*++tmp_str)); - while (tmp_str[0]) { - sub_str = strsep(&tmp_str, delimiter); + while ((sub_str = strsep(&tmp_str, delimiter)) != NULL) { ret = kstrtol(sub_str, 0, ¶meter[parameter_size]); if (ret) return -EINVAL; @@ -1038,8 +1037,7 @@ static ssize_t amdgpu_read_mask(const char *buf, size_t count, uint32_t *mask) memcpy(buf_cpy, buf, bytes); buf_cpy[bytes] = '\0'; tmp = buf_cpy; - while (tmp[0]) { - sub_str = strsep(&tmp, delimiter); + while ((sub_str = strsep(&tmp, delimiter)) != NULL) { if (strlen(sub_str)) { ret = kstrtol(sub_str, 0, &level); if (ret) @@ -1636,8 +1634,7 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev, i++; memcpy(buf_cpy, buf, count-i); tmp_str = buf_cpy; - while (tmp_str[0]) { - sub_str = strsep(&tmp_str, delimiter); + while ((sub_str = strsep(&tmp_str, delimiter)) != NULL) { ret = kstrtol(sub_str, 0, ¶meter[parameter_size]); if (ret) return -EINVAL; |