Commit 15b86c3d authored by Wolfgang Denk's avatar Wolfgang Denk Committed by Scott Wood

env_nand.c: print error message and fail gracefully

env_nand.c would crash silently if a malloc() for the environment
buffers failed; make it print an error message and fail gracefully,
i. e. use the default environment then.
Signed-off-by: default avatarWolfgang Denk <>
Acked-by: default avatarJohn Rigby <>
parent 674ef7bd
......@@ -298,6 +298,13 @@ void env_relocate_spec (void)
tmp_env1 = (env_t *) malloc(CONFIG_ENV_SIZE);
tmp_env2 = (env_t *) malloc(CONFIG_ENV_SIZE);
if ((tmp_env1 == NULL) || (tmp_env2 == NULL)) {
puts("Can't allocate buffers for environment\n");
free (tmp_env1);
free (tmp_env2);
return use_default();
if (readenv(CONFIG_ENV_OFFSET, (u_char *) tmp_env1))
puts("No Valid Environment Area Found\n");
if (readenv(CONFIG_ENV_OFFSET_REDUND, (u_char *) tmp_env2))
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment