drivers/gpu/drm/amd/amdgpu/mes_v12_1.c:1229 mes_v12_1_kiq_enable_queue() error: buffer overflow 'adev->mes.ring' 16 <= s32max

kernel test robot <[email protected]>
Newsgroups dev.linux.lists.oe-kbuild
Message-ID <[email protected]>
BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Jack Xiao <[email protected]>
CC: Alex Deucher <[email protected]>
CC: Hawking Zhang <[email protected]>
CC: Mukul Joshi <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   bcc44b6785f216eb939226ade6e3910baa30516b
commit: e220edf2d6fd6dbf08fa93790809500a80217948 drm/amdgpu/mes_v12_1: initial support for mes_v12_1
date:   8 months ago
:::::: branch date: 13 hours ago
:::::: commit date: 8 months ago
config: i386-randconfig-141-20260806 (https://download.01.org/0day-ci/archive/20260808/[email protected]/config)
compiler: clang version 22.1.3 (https://github.com/llvm/llvm-project e9846648fd6183ee6d8cbdb4502213fcf902a211)
smatch: v0.5.0-9187-g5189e3fb

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Fixes: e220edf2d6fd ("drm/amdgpu/mes_v12_1: initial support for mes_v12_1")
| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

New smatch warnings:
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c:1229 mes_v12_1_kiq_enable_queue() error: buffer overflow 'adev->mes.ring' 16 <= s32max
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c:1516 mes_v12_1_kiq_dequeue_sched() error: buffer overflow 'adev->mes.ring' 16 <= s32max
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c:1604 mes_v12_1_kiq_hw_fini() error: buffer overflow 'adev->mes.ring' 16 <= s32max
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c:1625 mes_v12_1_xcc_hw_init() error: buffer overflow 'adev->mes.ring' 16 <= s32max

Old smatch warnings:
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c:1607 mes_v12_1_kiq_hw_fini() error: buffer overflow 'adev->mes.ring' 16 <= s32max
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c:1612 mes_v12_1_kiq_hw_fini() error: buffer overflow 'adev->mes.ring' 16 <= s32max
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c:1680 mes_v12_1_xcc_hw_init() error: buffer overflow 'adev->mes.ring' 16 <= s32max

vim +1229 drivers/gpu/drm/amd/amdgpu/mes_v12_1.c

e220edf2d6fd6d Jack Xiao 2025-05-14  1213  
e220edf2d6fd6d Jack Xiao 2025-05-14  1214  static int mes_v12_1_kiq_enable_queue(struct amdgpu_device *adev, int xcc_id)
e220edf2d6fd6d Jack Xiao 2025-05-14  1215  {
e220edf2d6fd6d Jack Xiao 2025-05-14  1216  	struct amdgpu_kiq *kiq = &adev->gfx.kiq[xcc_id];
e220edf2d6fd6d Jack Xiao 2025-05-14  1217  	struct amdgpu_ring *kiq_ring = &adev->gfx.kiq[xcc_id].ring;
e220edf2d6fd6d Jack Xiao 2025-05-14  1218  	int r, inst = MES_PIPE_INST(xcc_id, AMDGPU_MES_SCHED_PIPE);
e220edf2d6fd6d Jack Xiao 2025-05-14  1219  
e220edf2d6fd6d Jack Xiao 2025-05-14  1220  	if (!kiq->pmf || !kiq->pmf->kiq_map_queues)
e220edf2d6fd6d Jack Xiao 2025-05-14  1221  		return -EINVAL;
e220edf2d6fd6d Jack Xiao 2025-05-14  1222  
e220edf2d6fd6d Jack Xiao 2025-05-14  1223  	r = amdgpu_ring_alloc(kiq_ring, kiq->pmf->map_queues_size);
e220edf2d6fd6d Jack Xiao 2025-05-14  1224  	if (r) {
e220edf2d6fd6d Jack Xiao 2025-05-14  1225  		DRM_ERROR("Failed to lock KIQ (%d).\n", r);
e220edf2d6fd6d Jack Xiao 2025-05-14  1226  		return r;
e220edf2d6fd6d Jack Xiao 2025-05-14  1227  	}
e220edf2d6fd6d Jack Xiao 2025-05-14  1228  
e220edf2d6fd6d Jack Xiao 2025-05-14 @1229  	kiq->pmf->kiq_map_queues(kiq_ring, &adev->mes.ring[inst]);
e220edf2d6fd6d Jack Xiao 2025-05-14  1230  
e220edf2d6fd6d Jack Xiao 2025-05-14  1231  	r = amdgpu_ring_test_ring(kiq_ring);
e220edf2d6fd6d Jack Xiao 2025-05-14  1232  	if (r) {
e220edf2d6fd6d Jack Xiao 2025-05-14  1233  		DRM_ERROR("kfq enable failed\n");
e220edf2d6fd6d Jack Xiao 2025-05-14  1234  		kiq_ring->sched.ready = false;
e220edf2d6fd6d Jack Xiao 2025-05-14  1235  	}
e220edf2d6fd6d Jack Xiao 2025-05-14  1236  	return r;
e220edf2d6fd6d Jack Xiao 2025-05-14  1237  }
e220edf2d6fd6d Jack Xiao 2025-05-14  1238  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.