From 7c6b5586470c34d4e4d880483eee995b23b68515 Mon Sep 17 00:00:00 2001 From: Elad Ashkenazi <18193363+elad335@users.noreply.github.com> Date: Tue, 15 Oct 2024 08:49:01 +0300 Subject: [PATCH] Improve sys_spu_thread_initialize --- rpcs3/Emu/Cell/lv2/sys_spu.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index 3f8ae570d7..d9aa0c53f3 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -562,6 +562,11 @@ error_code sys_spu_thread_initialize(ppu_thread& ppu, vm::ptr thread, u32 g sys_spu.warning("sys_spu_thread_initialize(thread=*0x%x, group=0x%x, spu_num=%d, img=*0x%x, attr=*0x%x, arg=*0x%x)", thread, group_id, spu_num, img, attr, arg); + if (spu_num >= std::size(decltype(lv2_spu_group::threads_map){})) + { + return CELL_EINVAL; + } + if (!attr) { return CELL_EFAULT; @@ -598,7 +603,7 @@ error_code sys_spu_thread_initialize(ppu_thread& ppu, vm::ptr thread, u32 g { case SYS_SPU_IMAGE_TYPE_KERNEL: { - const auto handle = idm::get(img->entry_point); + const auto handle = idm::get(image.entry_point); if (!handle) { @@ -703,11 +708,6 @@ error_code sys_spu_thread_initialize(ppu_thread& ppu, vm::ptr thread, u32 g return CELL_ESRCH; } - if (spu_num >= group->threads_map.size()) - { - return CELL_EINVAL; - } - std::unique_lock lock(group->mutex); if (auto state = +group->run_state; state != SPU_THREAD_GROUP_STATUS_NOT_INITIALIZED)