diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-07-29 11:00:57 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-07-29 11:00:57 +0000 |
commit | 26a536725767b105bc96de61d710cfd1d259b207 (patch) | |
tree | a605ae275a0af51cf8df34a639ad520c031ae69f /sys | |
parent | d5f0704610a5a532e22168bf01c3264699d484d9 (diff) |
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
Diffstat (limited to 'sys')
-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; |