[POWERPC] Fix alignment problem in rh_alloc_align() with exact-sized blocks

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>

authored by Timur Tabi and committed by Paul Mackerras 1c2de47c 991eb43a

+8 -14
+8 -14
arch/powerpc/lib/rheap.c
··· 468 if (blk->size == size) { 469 /* Move from free list to taken list */ 470 list_del(&blk->list); 471 - blk->owner = owner; 472 - start = blk->start; 473 474 - attach_taken_block(info, blk); 475 - 476 - return start; 477 } 478 479 - newblk = get_slot(info); 480 - newblk->start = blk->start; 481 - newblk->size = size; 482 newblk->owner = owner; 483 - 484 - /* blk still in free list, with updated start, size */ 485 - blk->start += size; 486 - blk->size -= size; 487 - 488 start = newblk->start; 489 - 490 attach_taken_block(info, newblk); 491 492 /* for larger alignment return fixed up pointer */
··· 468 if (blk->size == size) { 469 /* Move from free list to taken list */ 470 list_del(&blk->list); 471 + newblk = blk; 472 + } else { 473 + newblk = get_slot(info); 474 + newblk->start = blk->start; 475 + newblk->size = size; 476 477 + /* blk still in free list, with updated start, size */ 478 + blk->start += size; 479 + blk->size -= size; 480 } 481 482 newblk->owner = owner; 483 start = newblk->start; 484 attach_taken_block(info, newblk); 485 486 /* for larger alignment return fixed up pointer */