summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Müllner <christoph.muellner@theobroma-systems.com>2019-05-05 20:37:51 +0200
committerChristoph Müllner <christoph.muellner@theobroma-systems.com>2019-05-07 17:30:46 +0200
commit2b4d43a47d78b6e9e555ed5af7cf9cfda193ae47 (patch)
tree6777eeaccfc43fd269f06b5490ff0fcab8fc98ac
parentebcd15e3c2771925a637f309d3a22e3185718d46 (diff)
[noupstream] malloc-simple: Hang if alloc space is exhausted.
In general code should check if calls to malloc() return NULL. Additionally functions should check return values for errors. However, that's not mandatory. There is quite some code in U-Boot, which does not check results of invocations and silently ingores them. Most likely this is caused by developers, which don't see how a certain code could ever fail. But they don't see that code can and will change in future and break previously valid assumptions. This patch protects from writing to NULL, by introducing an endless loop in case the alloc space is exhausted. Signed-off-by: Christoph Müllner <christoph.muellner@theobroma-systems.com>
-rw-r--r--common/malloc_simple.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/common/malloc_simple.c b/common/malloc_simple.c
index 2467e636eb..56f729fae2 100644
--- a/common/malloc_simple.c
+++ b/common/malloc_simple.c
@@ -23,6 +23,7 @@ static void *alloc_simple(size_t bytes, int align)
gd->malloc_limit);
if (new_ptr > gd->malloc_limit) {
pr_err("alloc space exhausted\n");
+ for (;;);
return NULL;
}