diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index 3c745866b9..9b4732174d 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -1327,11 +1327,6 @@ error_code sys_fs_lseek(ppu_thread& ppu, u32 fd, s64 offset, s32 whence, vm::ptr sys_fs.trace("sys_fs_lseek(fd=%d, offset=0x%llx, whence=0x%x, pos=*0x%x)", fd, offset, whence, pos); - if (whence >= 3) - { - return {CELL_EINVAL, whence}; - } - const auto file = idm::get(fd); if (!file) @@ -1339,6 +1334,11 @@ error_code sys_fs_lseek(ppu_thread& ppu, u32 fd, s64 offset, s32 whence, vm::ptr return CELL_EBADF; } + if (whence + 0u >= 3) + { + return {CELL_EINVAL, whence}; + } + std::lock_guard lock(file->mp->mutex); const u64 result = file->file.seek(offset, static_cast(whence));