From 33ed95bd8e8aacc840d82039ae5a09f30cd5011d Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Tue, 2 Feb 2021 18:37:23 -0800 Subject: [PATCH] [kernel] Remove bitmask check in heap free Since all memory regions start with a header, this check should never pass. --- src/libraries/kutil/heap_allocator.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libraries/kutil/heap_allocator.cpp b/src/libraries/kutil/heap_allocator.cpp index 7dd66d2..a80e8f8 100644 --- a/src/libraries/kutil/heap_allocator.cpp +++ b/src/libraries/kutil/heap_allocator.cpp @@ -100,9 +100,8 @@ heap_allocator::free(void *p) { if (!p) return; - static constexpr uintptr_t bad_mask = (1 << min_order) - 1; uintptr_t addr = reinterpret_cast(p); - kassert(addr >= m_start && addr < m_end && !(addr & bad_mask), + kassert(addr >= m_start && addr < m_end, "Attempt to free non-heap pointer"); mem_header *header = reinterpret_cast(p);