Fixes from code review
Match redzone pattern set and check calls, use calculated physical addr
in call to dealloc_unmap, and minor formatting updates.
@@ -84,7 +84,7 @@ static void get_debug_alloc_size(bytes b, bytes padsize, bytes *nb, bytes *paddi
static u64 alloc_check(volatile mem_debug_hdr hdr, bytes b, bytes padding)
{
#ifdef MEMDBG_OVERRUN
- set_pattern(hdr, padding, &pat_redzone, sizeof(pat_redzone));
+ set_pattern(hdr + 1, padding - sizeof(*hdr), &pat_redzone, sizeof(pat_redzone));
set_pattern((u8 *)hdr + padding + b, padding, &pat_redzone, sizeof(pat_redzone));
#endif
hdr->sig = DBG_HDR_SIG;
@@ -172,7 +172,7 @@ static void mem_debug_backed_dealloc_unmap(backed_heap h, void *v, u64 p, bytes
get_debug_alloc_size(b, mdh->padsize, &nb, &padding);
mem_debug_hdr hdr = (mem_debug_hdr)pointer_from_u64(a - padding);
dealloc_check(hdr, a, b, nb, padding);
- dealloc_unmap(mdh->parent, hdr, 0, nb);
+ dealloc_unmap(mdh->parent, hdr, p - padding, nb);
}
static u64 mem_debug_backed_alloc(heap h, bytes b)
