diff options
author | Roman Kononov <kononov195-uclibc@yahoo.com> | 2007-02-01 14:21:03 -0800 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2007-02-02 11:37:19 +0900 |
commit | 3d15dc049d5771d2e9b0e808ad3554fd1158b1ac (patch) | |
tree | 97ef1751593c643453f621d5d76893455d609462 /kexec/kexec.c | |
parent | a6eee1488fd9a9fb3ca483eed92977dd9e4cacb6 (diff) |
xmalloc; empty memory ranges
This patch fixes zero-size xmalloc failure, which I ran
across with a uClibc implementation of malloc(), kexec'ing
x86_64 vmlinux.
Additionally, it removes inefficiencies related to creating
zero-sized memory ranges, which I noticed under the same
conditions.
Signed-off-by: Roman Kononov <kononov195-uclibc@yahoo.com>
Reformated and rediffed as it wouldn't apply to my tree for some reason.
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/kexec.c')
-rw-r--r-- | kexec/kexec.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/kexec/kexec.c b/kexec/kexec.c index a1e9317..f8dda82 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -58,6 +58,8 @@ void *xmalloc(size_t size) { void *buf; buf = malloc(size); + if (!size) + return NULL; if (!buf) { die("Cannot malloc %ld bytes: %s\n", size + 0UL, strerror(errno)); @@ -224,7 +226,7 @@ unsigned long locate_hole(struct kexec_info *info, mstart = send +1; j++; } - if (mstart <= mend) { + if (mstart < mend) { mem_range[mem_ranges].start = mstart; mem_range[mem_ranges].end = mend; mem_range[mem_ranges].type = RANGE_RAM; |