[POWERPC] Fix alignment problem in rh_alloc_align() with exact-sized blocks
authorTimur Tabi <timur@freescale.com>
Mon, 14 May 2007 16:31:26 +0000 (11:31 -0500)
committerPaul Mackerras <paulus@samba.org>
Thu, 17 May 2007 11:10:16 +0000 (21:10 +1000)
When an rheap is created, the caller can specify the alignment to use.  In
rh_alloc_align(), if a free block is found that is the exact size needed
(including extra space for alignment), that configured alignment value is not
used to align the pointer.  Instead, the default alignment is used.  If the
default alignment is smaller than the configured alignment, then the returned
value will not be aligned correctly.

Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
arch/powerpc/lib/rheap.c

index b2f6dcc59600bb5c6d21c753b0eb6058491ca260..180ee2933ab96ffacd076c1e0ae67aac57e002c1 100644 (file)
@@ -468,25 +468,19 @@ unsigned long rh_alloc_align(rh_info_t * info, int size, int alignment, const ch
        if (blk->size == size) {
                /* Move from free list to taken list */
                list_del(&blk->list);
-               blk->owner = owner;
-               start = blk->start;
-
-               attach_taken_block(info, blk);
+               newblk = blk;
+       } else {
+               newblk = get_slot(info);
+               newblk->start = blk->start;
+               newblk->size = size;
 
-               return start;
+               /* blk still in free list, with updated start, size */
+               blk->start += size;
+               blk->size -= size;
        }
 
-       newblk = get_slot(info);
-       newblk->start = blk->start;
-       newblk->size = size;
        newblk->owner = owner;
-
-       /* blk still in free list, with updated start, size */
-       blk->start += size;
-       blk->size -= size;
-
        start = newblk->start;
-
        attach_taken_block(info, newblk);
 
        /* for larger alignment return fixed up pointer  */