diff options
author | Andreas Fenkart <afenkart@gmail.com> | 2017-04-08 09:59:33 (GMT) |
---|---|---|
committer | Jagan Teki <jagan@openedev.com> | 2017-05-03 05:48:06 (GMT) |
commit | c041c60c6c5c1eafcff21eec76e16ee958a7506e (patch) | |
tree | 60654ebe3680fe2b0cd67cc1496f601d785a2b6e /common/env_sf.c | |
parent | 8fee8845e7543aec3edd64fcef2d6ff268d65a0d (diff) | |
download | u-boot-c041c60c6c5c1eafcff21eec76e16ee958a7506e.tar.xz |
env_sf: re-order error handling in single-buffer env_relocate_spec
this makes it easier comparable to the double-buffered version
Signed-off-by: Andreas Fenkart <afenkart@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jagan Teki <jagan@openedev.com>
Tested-by: Jagan Teki <jagan@openedev.com>
Diffstat (limited to 'common/env_sf.c')
-rw-r--r-- | common/env_sf.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/common/env_sf.c b/common/env_sf.c index a52fb73..6a1583e 100644 --- a/common/env_sf.c +++ b/common/env_sf.c @@ -313,29 +313,31 @@ void env_relocate_spec(void) char *buf = NULL; buf = (char *)memalign(ARCH_DMA_MINALIGN, CONFIG_ENV_SIZE); - - ret = setup_flash_device(); - if (ret) { - if (buf) - free(buf); + if (!buf) { + set_default_env("!malloc() failed"); return; } + ret = setup_flash_device(); + if (ret) + goto out; + ret = spi_flash_read(env_flash, CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, buf); if (ret) { set_default_env("!spi_flash_read() failed"); - goto out; + goto err_read; } ret = env_import(buf, 1); if (ret) gd->env_valid = 1; -out: + +err_read: spi_flash_free(env_flash); - if (buf) - free(buf); env_flash = NULL; +out: + free(buf); } #endif |