]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sandbox: handling out of memory
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Thu, 4 Jun 2020 17:28:22 +0000 (19:28 +0200)
committerSimon Glass <sjg@chromium.org>
Fri, 10 Jul 2020 00:57:21 +0000 (18:57 -0600)
assert() only works in debug mode. So checking a successful memory
allocation should not use assert().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sandbox/cpu/state.c

index 1f794123b36e56785007e12f27cc6e3354a14be7..34b6fff7e7a8669eeb147486230b8f742bdd4999 100644 (file)
@@ -378,7 +378,10 @@ int state_init(void)
 
        state->ram_size = CONFIG_SYS_SDRAM_SIZE;
        state->ram_buf = os_malloc(state->ram_size);
-       assert(state->ram_buf);
+       if (!state->ram_buf) {
+               printf("Out of memory\n");
+               os_exit(1);
+       }
 
        state_reset_for_test(state);
        /*