Skip to content

Commit

Permalink
[POWERPC] Fix array indexing error in rheap grow()
Browse files Browse the repository at this point in the history
The grow() function in the rheap library allocates a larger array of blocks,
copies the contents of the old blocks array to the newly allocated array and
fixes the list_head pointers after the copy.  At the end, the new blocks must
be enqueued to the empty_list of the rh_info_t structure.  This patch fixes
a bug where the code was indexing past the end of the array when enqueueing
blocks.  The UCC ethernet driver, which uses the rheap allocator, experiences
kernel panics because of this bug.

Signed-off-by: Ionut Nicu <ionut.nicu@freescale.com>
Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Timur Tabi authored and Paul Mackerras committed Feb 7, 2007
1 parent 5f3162f commit 4942bd8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/powerpc/lib/rheap.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ static int grow(rh_info_t * info, int max_blocks)
info->flags &= ~RHIF_STATIC_BLOCK;

/* add all new blocks to the free list */
for (i = 0, blk = block + info->max_blocks; i < new_blocks; i++, blk++)
blk = block + info->max_blocks - new_blocks;
for (i = 0; i < new_blocks; i++, blk++)
list_add(&blk->list, &info->empty_list);

return 0;
Expand Down

0 comments on commit 4942bd8

Please sign in to comment.