summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-01-15 03:59:51 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2008-01-15 03:59:51 (GMT)
commitf2d4eec1ecac9fec07c195399c640c4f9641a732 (patch)
treeb726e10eae97d130a87f39160f4d57d7560b2e54
parent41085c94384c3a610c25d9343d555c0f66d2a0b2 (diff)
downloadlpsm-f2d4eec1ecac9fec07c195399c640c4f9641a732.zip
lpsm-f2d4eec1ecac9fec07c195399c640c4f9641a732.tar.gz
lpsm-f2d4eec1ecac9fec07c195399c640c4f9641a732.tar.bz2
lpsm-f2d4eec1ecac9fec07c195399c640c4f9641a732.tar.xz
Fix SLAB bitmap corruption on 64-bit platforms
The start of the SLAB bitmap was calculated differently malloc and free, with expected disastrous consequences. This didn't affect 32-bit platforms by sheer coincidence.
-rw-r--r--free.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/free.c b/free.c
index 21d9c9a..c33485c 100644
--- a/free.c
+++ b/free.c
@@ -97,8 +97,7 @@ void lpsm_free_slab(void *ptr)
sh = (struct slab_header *)((uintptr_t)ptr & ~(BUDDY_SIZE_MIN-1));
assert(sh->magic == SLAB_MAGIC);
si = &AH->slab[sh->index];
- slab_bitmap = (unsigned char *)sh +
- ((sizeof(struct slab_header)+MINIMUM_ALIGN-1) & ~MINIMUM_ALIGN_MASK);
+ slab_bitmap = (unsigned char *)(sh+1);
DPRINTF(("slab: Freeing size %d slab at %p, %d/%d allocated\n",
si->size, ptr, si->count-sh->free_count, si->count));