mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/3] bzip2/lzma/gzip: pre-boot malloc doesn't return NULL on failure
@ 2009-12-14 21:45 Phillip Lougher
  2009-12-15 22:57 ` [tip:x86/urgent] " tip-bot for Phillip Lougher
  0 siblings, 1 reply; 2+ messages in thread
From: Phillip Lougher @ 2009-12-14 21:45 UTC (permalink / raw)
  To: linux-kernel, linux-embedded, akpm; +Cc: phillip, mingo, albin.tonnerre


The trivial malloc implementation used in the pre-boot environment by the
decompressors returns a bad pointer on failure (falling through after
calling error).  This is doubly wrong - the callers expect malloc to
return NULL on failure, second the error function is intended to be
used by the decompressors to propagate errors to *their* callers.  The
decompressors have no access to any state set by the error function.

Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
---
 include/linux/decompress/mm.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
index 12ff8c3..5032b9a 100644
--- a/include/linux/decompress/mm.h
+++ b/include/linux/decompress/mm.h
@@ -25,7 +25,7 @@ static void *malloc(int size)
 	void *p;
 
 	if (size < 0)
-		error("Malloc error");
+		return NULL;
 	if (!malloc_ptr)
 		malloc_ptr = free_mem_ptr;
 
@@ -35,7 +35,7 @@ static void *malloc(int size)
 	malloc_ptr += size;
 
 	if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr)
-		error("Out of memory");
+		return NULL;
 
 	malloc_count++;
 	return p;
-- 
1.6.3.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-12-15 22:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-14 21:45 [PATCH 1/3] bzip2/lzma/gzip: pre-boot malloc doesn't return NULL on failure Phillip Lougher
2009-12-15 22:57 ` [tip:x86/urgent] " tip-bot for Phillip Lougher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®