summaryrefslogtreecommitdiff
path: root/src/kernel/syscalls.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/syscalls.c')
-rw-r--r--src/kernel/syscalls.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c
index a2ae5dd..f884fd3 100644
--- a/src/kernel/syscalls.c
+++ b/src/kernel/syscalls.c
@@ -317,6 +317,11 @@ void __user *_syscall_memflag(void __user *addr, size_t len, int flags) {
SYSCALL_RETURN((uintptr_t)addr);
}
+ if (!(flags & MEMFLAG_PRESENT)) {
+ pagedir_unmap_user(pages, addr, len);
+ SYSCALL_RETURN((uintptr_t)addr);
+ }
+
for (userptr_t iter = addr; iter < addr + len; iter += PAGE_SIZE) {
if (pagedir_iskern(pages, iter)) {
@@ -325,13 +330,6 @@ void __user *_syscall_memflag(void __user *addr, size_t len, int flags) {
}
phys = pagedir_virt2phys(pages, iter, false, false);
-
- if (!(flags & MEMFLAG_PRESENT)) {
- if (phys)
- page_free(pagedir_unmap(pages, iter), 1);
- continue;
- }
-
if (!phys) {
phys = page_alloc(1);
memset(phys, 0, PAGE_SIZE); // TODO somehow test this