From 7261ef381a2c3c7bf5ef0ecd2392f7cab9e60e37 Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Sat, 4 Jul 2009 05:10:28 +0000 Subject: mem-pool: Do not perform chunkhead2ptr on MALLOCed memory Memory allocated from the heap instead of the mem-pool need not under go the chunkhead to ptr conversion when returning to a mem-pool user since this address can be use directly. This fixes a crash in io-threads. Ref: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=102 Signed-off-by: Anand V. Avati --- libglusterfs/src/mem-pool.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c index 90df2f39e..3937fcc37 100644 --- a/libglusterfs/src/mem-pool.c +++ b/libglusterfs/src/mem-pool.c @@ -118,8 +118,12 @@ mem_get (struct mem_pool *mem_pool) * allocator is coming RSN. */ ptr = MALLOC (mem_pool->real_sizeof_type); - if (!ptr) - goto unlocked_out; + + /* Memory coming from the heap need not be transformed from a + * chunkhead to a usable pointer since it is not coming from + * the pool. + */ + goto unlocked_out; } fwd_addr_out: ptr = mem_pool_chunkhead2ptr (ptr); -- cgit