From 5db7ba5dbc87daf361397ac727f146e0565db1a9 Mon Sep 17 00:00:00 2001 From: Zhang Yanfei Date: Thu, 14 Mar 2013 01:16:25 +0800 Subject: kexec: check size before trying the malloc If size is zero, it is unnecessary to do the malloc operation. So checking size first is better than doing malloc first. Signed-off-by: Zhang Yanfei Signed-off-by: Simon Horman --- kexec/kexec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'kexec/kexec.c') diff --git a/kexec/kexec.c b/kexec/kexec.c index 3ef6f0d..494c5b3 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -76,9 +76,9 @@ static char *xstrdup(const char *str) void *xmalloc(size_t size) { void *buf; - buf = malloc(size); if (!size) return NULL; + buf = malloc(size); if (!buf) { die("Cannot malloc %ld bytes: %s\n", size + 0UL, strerror(errno)); -- cgit