From ff7c50c627ce7c03db404875ae38113b8e08c0bd Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 12 Apr 2023 00:24:02 +0300 Subject: [PATCH] Kernel: kmalloc does not check for corruptiong unless it cannot allocate We 'don't care' if kmalloc is corrupted unless it prevents us from allocating memory. Scheduler should be catching stack overflows either way and is much more efficient --- kernel/kernel/kmalloc.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kernel/kernel/kmalloc.cpp b/kernel/kernel/kmalloc.cpp index d32a4f6c..010dec11 100644 --- a/kernel/kernel/kmalloc.cpp +++ b/kernel/kernel/kmalloc.cpp @@ -341,9 +341,7 @@ void* kmalloc(size_t size, size_t align) if (ptrdiff_t rem = size % s_kmalloc_min_align) size += s_kmalloc_min_align - rem; - - ASSERT(!is_corrupted()); - + if (void* res = kmalloc_impl(size, align)) return res; @@ -352,6 +350,7 @@ void* kmalloc(size_t size, size_t align) dwarnln(" {6H} free", s_kmalloc_info.free); debug_dump(); Debug::dump_stack_trace(); + ASSERT(!is_corrupted()); return nullptr; } @@ -399,8 +398,6 @@ void kfree(void* address) } else if (s_kmalloc_info.base <= address_uint && address_uint < s_kmalloc_info.end) { - ASSERT(!is_corrupted()); - auto& info = s_kmalloc_info; auto* node = info.from_address(address);