From: Timur Tabi Date: Sat, 27 Jan 2007 23:41:49 +0000 (-0600) Subject: [POWERPC] Fix array indexing error in rheap grow() X-Git-Tag: v2.6.21-rc1~92^2~23^2~53 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4942bd80e83d13bf394df4a8109bee39d861820f;p=linux-2.6 [POWERPC] Fix array indexing error in rheap grow() 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 Signed-off-by: Timur Tabi Signed-off-by: Paul Mackerras --- diff --git a/arch/powerpc/lib/rheap.c b/arch/powerpc/lib/rheap.c index 57bf991ccd..4bbda6b2be 100644 --- a/arch/powerpc/lib/rheap.c +++ b/arch/powerpc/lib/rheap.c @@ -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;