diff options
| author | Wolfgang Denk <wd@denx.de> | 2010-01-16 21:50:26 -0700 | 
|---|---|---|
| committer | Scott Wood <scottwood@freescale.com> | 2010-01-27 14:22:41 -0600 | 
| commit | 15b86c3d6c9a5a2e917b73d758a556568430021a (patch) | |
| tree | d0eae22818a6e0f2863f63967a1e040a9247f567 /common/env_nand.c | |
| parent | 674ef7bd02de948b6d8757f6a43a6f2fa4d88769 (diff) | |
| download | olio-uboot-2014.01-15b86c3d6c9a5a2e917b73d758a556568430021a.tar.xz olio-uboot-2014.01-15b86c3d6c9a5a2e917b73d758a556568430021a.zip | |
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: Wolfgang Denk <wd@denx.de>
Acked-by: John Rigby <jcrigby@gmail.com>
Diffstat (limited to 'common/env_nand.c')
| -rw-r--r-- | common/env_nand.c | 7 | 
1 files changed, 7 insertions, 0 deletions
| diff --git a/common/env_nand.c b/common/env_nand.c index ca631af19..a15a95090 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -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)) |