Subject: [PATCH HACK kexec-tools-testing] malloc corruption hack

From: Milton Miller <[email-masked]>
Date: Wed, 11 Apr 2007 03:29:21 -0500 (CDT)

On a system with rtas, a hash table, no pci, and one memory node I
got the following error:

*** glibc detected *** double free or corruption (out): 0x0000000010115800 ***
kexec-reboot: line 9:  2366 Aborted                 \
  ./kexec --mem-max=0x20000000 -l /root/vmlinux --devicetreeblob=dtall.dtb

The problem is count_memory_ranges doesn't count what get_devtree_details
will be adding to the exlcude list.

This is a very gross hack to get around the problem, I post it so others
might benifit until the real problem is fixed.

However, I would also like to point out that the code is deficent, as it
is only looking for the properties in specific directories.  It should
be looking in all directories for the properties, like the reserve code
building the device tree.   TCE (iommu) tables can be attached to any
pci bus.  Also, it allows other ranges to be reserved by just changing
the device tree, instead of adding new searches to kexec-tools.

--- 
Thanks to Sonny for getting a debug envrionment laoded to debug this failure.

--- kexec-tools-testing/kexec/arch/ppc64/kexec-ppc64.c.orig	2007-04-10 22:29:59.000000000 -0500
+++ kexec-tools-testing/kexec/arch/ppc64/kexec-ppc64.c	2007-04-10 22:30:21.000000000 -0500
@@ -124,6 +124,8 @@ static int count_memory_ranges()
 	}
 	closedir(dir);
 
+	max_memory_ranges += 5;	/* base exclude ranges - kernel, rtas, etc */
+
 	return 0;
 }