]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: fix potential overflow in fs_info.debugfs_name
authorStanley.Yang <Stanley.Yang@amd.com>
Mon, 11 May 2026 08:49:19 +0000 (16:49 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 27 May 2026 14:40:33 +0000 (10:40 -0400)
Use snprintf() with sizeof(fs_info.debugfs_name) so a long RAS block
name plus the "_err_inject" suffix cannot overflow the 32-byte buffer.

Signed-off-by: Stanley.Yang <Stanley.Yang@amd.com>
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

index 3e1f8b15f75de01570639a36716e2166e1366a0f..093c0bf760c161554c4f170ff7e097adc51e45c6 100644 (file)
@@ -2280,7 +2280,8 @@ void amdgpu_ras_debugfs_create_all(struct amdgpu_device *adev)
        list_for_each_entry(obj, &con->head, node) {
                if (amdgpu_ras_is_supported(adev, obj->head.block) &&
                        (obj->attr_inuse == 1)) {
-                       sprintf(fs_info.debugfs_name, "%s_err_inject",
+                       snprintf(fs_info.debugfs_name, sizeof(fs_info.debugfs_name),
+                                       "%s_err_inject",
                                        get_ras_block_str(&obj->head));
                        fs_info.head = obj->head;
                        amdgpu_ras_debugfs_create(adev, &fs_info, dir);