Skip to content

Commit

Permalink
kernel:fix sys_osem_trywait merge issue
Browse files Browse the repository at this point in the history
fix sys_osem_post on wrong descriptor
  • Loading branch information
DHrpcs3 committed Nov 21, 2024
1 parent afde24f commit 661a718
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion orbis-kernel/src/sys/sys_sce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,9 @@ orbis::SysResult orbis::sys_osem_trywait(Thread *thread, sint id, sint need) {
return ErrorCode::BADF;
}

if (need < 1 || need > sem->maxValue) {
return ErrorCode::INVAL;
}

std::lock_guard lock(sem->mtx);
if (sem->isDeleted || sem->value < need)
Expand All @@ -620,8 +622,12 @@ orbis::SysResult orbis::sys_osem_trywait(Thread *thread, sint id, sint need) {
orbis::SysResult orbis::sys_osem_post(Thread *thread, sint id, sint count) {
ORBIS_LOG_TRACE(__FUNCTION__, thread, id, count);
Ref<Semaphore> sem = thread->tproc->semMap.get(id);
if (count < 1 || count > sem->maxValue - sem->value)
if (sem == nullptr) {
return ErrorCode::BADF;
}
if (count < 1 || count > sem->maxValue - sem->value) {
return ErrorCode::INVAL;
}

std::lock_guard lock(sem->mtx);
if (sem->isDeleted)
Expand Down

0 comments on commit 661a718

Please sign in to comment.