diff mbox

[U-Boot,09/10] malloc_simple: Display an error when memory is exhausted

Message ID 1451391772-6203-10-git-send-email-sjg@chromium.org
State Rejected
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass Dec. 29, 2015, 12:22 p.m. UTC
This is an uncommon but annoying case. Normal error handling will ensure it
is reported, but it is useful to have a message which provides a little more
detail.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/malloc_simple.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/common/malloc_simple.c b/common/malloc_simple.c
index 479a1e4..4621b6d 100644
--- a/common/malloc_simple.c
+++ b/common/malloc_simple.c
@@ -21,8 +21,11 @@  void *malloc_simple(size_t bytes)
 	new_ptr = gd->malloc_ptr + bytes;
 	debug("%s: size=%zx, ptr=%lx, limit=%lx\n", __func__, bytes, new_ptr,
 	      gd->malloc_limit);
-	if (new_ptr > gd->malloc_limit)
+	if (new_ptr > gd->malloc_limit) {
+		printf("Out of memory (%zu bytes, %lx requested)\n", bytes,
+		       new_ptr);
 		return NULL;
+	}
 	ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes);
 	gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));