sceKernelReleaseDirectMemory fix (#2623)

* Fix error return on sceKernelMunmap

FreeBSD docs state that len <= 0 is a EINVAL return.

* Early return on ReleaseDirectMemory with len = 0

Calls to these two functions with len = 0 cause an assert in CarveDmemArea. Since there's no memory to release, an early return should be safe here.

* Remove check for negative length in munmap

Addresses review comment
This commit is contained in:
Stephen Miller 2025-03-09 08:12:05 -05:00 committed by GitHub
parent 6b3746f3a6
commit 0e315cbd8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -79,6 +79,9 @@ s32 PS4_SYSV_ABI sceKernelAllocateMainDirectMemory(size_t len, size_t alignment,
}
s32 PS4_SYSV_ABI sceKernelCheckedReleaseDirectMemory(u64 start, size_t len) {
if (len == 0) {
return ORBIS_OK;
}
LOG_INFO(Kernel_Vmm, "called start = {:#x}, len = {:#x}", start, len);
auto* memory = Core::Memory::Instance();
memory->Free(start, len);
@ -86,6 +89,9 @@ s32 PS4_SYSV_ABI sceKernelCheckedReleaseDirectMemory(u64 start, size_t len) {
}
s32 PS4_SYSV_ABI sceKernelReleaseDirectMemory(u64 start, size_t len) {
if (len == 0) {
return ORBIS_OK;
}
auto* memory = Core::Memory::Instance();
memory->Free(start, len);
return ORBIS_OK;
@ -507,7 +513,7 @@ s32 PS4_SYSV_ABI sceKernelConfiguredFlexibleMemorySize(u64* sizeOut) {
int PS4_SYSV_ABI sceKernelMunmap(void* addr, size_t len) {
LOG_INFO(Kernel_Vmm, "addr = {}, len = {:#x}", fmt::ptr(addr), len);
if (len == 0) {
return ORBIS_OK;
return ORBIS_KERNEL_ERROR_EINVAL;
}
auto* memory = Core::Memory::Instance();
return memory->UnmapMemory(std::bit_cast<VAddr>(addr), len);