[PATCH kexec-tools 1/5] ppc64: always check number of ranges when adding

Michael Ellerman michael at ellerman.id.au
Wed Jan 7 13:42:52 EST 2009


On Fri, 2009-01-02 at 15:04 -0600, Milton Miller wrote:
> make the idom "always call realloc_memory_ranges when filling a range entry"
> 
> kexec was core dumping after using 5 exclude_range pairs when only 3
> were allocated.
> 
> also delcare realloc_memory_ranges to take no arguments.
> 
> Signed-off-by: Milton Miller <miltonm at bga.com>
> 
> Index: kexec-tools/kexec/arch/ppc64/kexec-ppc64.c
> ===================================================================
> --- kexec-tools.orig/kexec/arch/ppc64/kexec-ppc64.c	2009-01-02 02:08:58.000000000 -0600
> +++ kexec-tools/kexec/arch/ppc64/kexec-ppc64.c	2009-01-02 02:09:08.000000000 -0600
> @@ -96,7 +96,7 @@ err1:
>  
>  }
>  
> -static int realloc_memory_ranges()
> +static int realloc_memory_ranges(void)
>  {
>  	size_t memory_range_len;
>  
> @@ -469,6 +469,8 @@ static int get_devtree_details(unsigned 
>  				exclude_range[i].start = initrd_start;
>  				exclude_range[i].end = initrd_end;
>  				i++;
> +				if (i >= max_memory_ranges)
> +					realloc_memory_ranges();
>  			}
>  		} /* chosen */
>  
> @@ -581,6 +583,8 @@ static int get_devtree_details(unsigned 
>  			exclude_range[i].start = tce_base;
>  			exclude_range[i].end = tce_base + tce_size;
>  			i++;
> +			if (i >= max_memory_ranges)
> +				realloc_memory_ranges();
>  			if (kexec_flags & KEXEC_ON_CRASH)
>  				add_usable_mem_rgns(tce_base, tce_size);
>  			closedir(cdir);
> @@ -634,6 +638,8 @@ int setup_memory_ranges(unsigned long ke
>  				memory_range[j].end = exclude_range[i].start - 1;
>  				memory_range[j].type = RANGE_RAM;
>  				j++;
> +				if (j >= max_memory_ranges)
> +					realloc_memory_ranges();
>  			}
>  		} /* i == 0 */
>  		/* If the last exclude range does not end at memory_max, include
> @@ -646,6 +652,8 @@ int setup_memory_ranges(unsigned long ke
>  				memory_range[j].end = memory_max;
>  				memory_range[j].type = RANGE_RAM;
>  				j++;
> +				if (j >= max_memory_ranges)
> +					realloc_memory_ranges();
>  				/* Limit the end to rmo_top */
>  				if (memory_range[j-1].start >= rmo_top) {
>  					j--;
> @@ -666,6 +674,8 @@ int setup_memory_ranges(unsigned long ke
>  		memory_range[j].end = exclude_range[i+1].start - 1;
>  		memory_range[j].type = RANGE_RAM;
>  		j++;
> +		if (i >= max_memory_ranges)
> +			realloc_memory_ranges();

Should this be checking against i or j?

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20090107/a05636c0/attachment.pgp>


More information about the Linuxppc-dev mailing list