]> git.ipfire.org Git - thirdparty/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 15:59:00 +0000 (11:59 -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>
(cherry picked from commit 1a58070fda26857a8f6acc0ab05428e60d5c6844)

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

index 6c644cfe6695d80cf61faf9c519f7613b52ee26b..fc9f3adf99122a993fea3f7e6daf014984212a76 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);