fix memory direct query

i wish there were tests for this
This commit is contained in:
martin 2024-09-03 20:21:38 -04:00
parent ab60f290dc
commit 5535e51f82

View File

@ -332,13 +332,17 @@ int MemoryManager::DirectMemoryQuery(PAddr addr, bool find_next,
std::scoped_lock lk{mutex}; std::scoped_lock lk{mutex};
auto dmem_area = FindDmemArea(addr); auto dmem_area = FindDmemArea(addr);
while (dmem_area != dmem_map.end() && dmem_area->second.is_free && find_next) { if (addr >= dmem_area->second.base + dmem_area->second.size) {
dmem_area++; if (!find_next) {
} LOG_ERROR(Core, "Unable to find allocated direct memory region to query!");
return ORBIS_KERNEL_ERROR_EACCES;
}
if (dmem_area == dmem_map.end() || dmem_area->second.is_free) { dmem_area++;
LOG_ERROR(Core, "Unable to find allocated direct memory region to query!"); if (dmem_area == dmem_map.end()) {
return ORBIS_KERNEL_ERROR_EACCES; LOG_ERROR(Core, "Unable to find allocated direct memory region to query!");
return ORBIS_KERNEL_ERROR_EACCES;
}
} }
const auto& area = dmem_area->second; const auto& area = dmem_area->second;