summaryrefslogtreecommitdiff
path: root/kexec/arch/ppc64/crashdump-ppc64.c
diff options
context:
space:
mode:
authorSachin P. Sant <sachinp@in.ibm.com>2006-12-22 12:34:55 +0530
committerSimon Horman <horms@verge.net.au>2006-12-25 11:32:12 +0900
commit7792798a79b78a5d566f70c9f00237d050b01350 (patch)
tree78e24530115805e19eeea397f184218617ece52d /kexec/arch/ppc64/crashdump-ppc64.c
parent64d74e97fddefa8241fb493fa5b497625317342c (diff)
ppc64: Dynamic mem allocation kexec tools Cleanup update
Here is a update to the previously submitted patch to dynamically allocate memory for memory range data structures. This patch adds following functionality * memset all allocated memory ranges pointers. * Simplify some of the code related to memory ranges allocation. Signed-off-by : Sachin Sant <sachinp@in.ibm.com> * Removed trailing whitespace Signed-off-by : Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/arch/ppc64/crashdump-ppc64.c')
-rw-r--r--kexec/arch/ppc64/crashdump-ppc64.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c
index 39879af..33d4b18 100644
--- a/kexec/arch/ppc64/crashdump-ppc64.c
+++ b/kexec/arch/ppc64/crashdump-ppc64.c
@@ -105,17 +105,18 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
DIR *dir, *dmem;
FILE *file;
struct dirent *dentry, *mentry;
- int i, n;
+ int i, n, crash_rng_len = 0;
unsigned long long start, end, cstart, cend;
crash_max_memory_ranges = max_memory_ranges + 6;
+ crash_rng_len = sizeof(struct memory_range) * crash_max_memory_ranges;
- crash_memory_range = (struct memory_range *) malloc(
- (sizeof(struct memory_range) * (crash_max_memory_ranges)));
+ crash_memory_range = (struct memory_range *) malloc(crash_rng_len);
if (!crash_memory_range) {
fprintf(stderr, "Allocation for crash memory range failed\n");
return -1;
}
+ memset(crash_memory_range, 0, crash_rng_len);
/* create a separate program header for the backup region */
crash_memory_range[0].start = BACKUP_SRC_START;
@@ -154,7 +155,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
closedir(dir);
goto err;
}
- if (memory_ranges >= max_memory_ranges) {
+ if (memory_ranges >= (max_memory_ranges + 1)) {
/* No space to insert another element. */
fprintf(stderr,
"Error: Number of crash memory ranges"