|
|
|
[PATCH] Clean up memory allocations in locate_hole() | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
* Exit if malloc fails - previously the error was ignored
* Free allocated memory before returning
Signed-off-by: Simon Horman <horms at verge.net.au>
Index: kexec-tools-unstable/kexec/kexec.c
===================================================================
--- kexec-tools-unstable.orig/kexec/kexec.c 2007-02-01 11:50:28.000000000 +0900
+++ kexec-tools-unstable/kexec/kexec.c 2007-02-01 11:50:32.000000000 +0900
@@ -197,6 +197,10 @@
/* Compute the free memory ranges */
max_mem_ranges = memory_ranges + info->nr_segments;
mem_range = malloc(max_mem_ranges *sizeof(struct memory_range));
+ if (!mem_range) {
+ perror("locate_hole: malloc");
+ exit(-1);
+ }
mem_ranges = 0;
/* Perform a merge on the 2 sorted lists of memory ranges */
@@ -265,6 +269,7 @@
}
}
}
+ free(mem_range);
if (hole_base == ULONG_MAX) {
fprintf(stderr, "Could not find a free area of memory of "
"%lx bytes...\n", hole_size);
[Netdev] [Linux Wireless] [Kernel Newbies] [Security] [Linux for Hams] [Netfilter] [Bugtraq] [Photo] [Yosemite] [Yosemite Forum] [MIPS Linux] [ARM Linux] [Linux RAID] [Linux Admin] [Samba] [Linux Media] [Linux Resources]