summaryrefslogtreecommitdiff
path: root/kernel/fs/shm.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-04-13 21:07:02 +0200
committerAnton Kling <anton@kling.gg>2024-04-13 21:07:02 +0200
commit92f848244796881994c1f147633123c45da219b6 (patch)
tree4ad209b6ede26b8475b7f0c6afb2382336dbbac7 /kernel/fs/shm.c
parent008b84bf5308d2f180905130653a656bfedccf8c (diff)
Kernel: Don't hard fail if the kernel can't allocate memory.
Currently this is just a improvement of error handling but it should also try to free up memory where it is possible.
Diffstat (limited to 'kernel/fs/shm.c')
-rw-r--r--kernel/fs/shm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/fs/shm.c b/kernel/fs/shm.c
index 2a2995b..0735efc 100644
--- a/kernel/fs/shm.c
+++ b/kernel/fs/shm.c
@@ -60,7 +60,9 @@ int shm_ftruncate(vfs_fd_t *fd, size_t length) {
}
p->real_pointer = mmu_find_unallocated_virtual_range(NULL, length);
- mmu_allocate_region(p->real_pointer, length, MMU_FLAG_RW, NULL);
+ if (!mmu_allocate_region(p->real_pointer, length, MMU_FLAG_RW, NULL)) {
+ return -ENOMEM;
+ }
p->size = length;
p->virtual_object = p->real_pointer;