]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/pm: fix null pointer access
authorUmio Yasuno <coelacanth_dream@protonmail.com>
Tue, 15 Jul 2025 14:44:35 +0000 (14:44 +0000)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 16 Jul 2025 20:17:21 +0000 (16:17 -0400)
Writing a string without delimiters (' ', '\n', '\0') to the under
gpu_od/fan_ctrl sysfs or pp_power_profile_mode for the CUSTOM profile
will result in a null pointer dereference.

Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4401
Signed-off-by: Umio Yasuno <coelacanth_dream@protonmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/amdgpu_pm.c

index 4b151bbaffaadd88dbc99ed50f9dbb26bf264aca..4b64851fdb42e4bb47dc4d3df2a5004ded55c149 100644 (file)
@@ -1398,6 +1398,8 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev,
                        if (ret)
                                return -EINVAL;
                        parameter_size++;
+                       if (!tmp_str)
+                               break;
                        while (isspace(*tmp_str))
                                tmp_str++;
                }
@@ -3645,6 +3647,9 @@ static int parse_input_od_command_lines(const char *buf,
                        return -EINVAL;
                parameter_size++;
 
+               if (!tmp_str)
+                       break;
+
                while (isspace(*tmp_str))
                        tmp_str++;
        }