[U-Boot] [PATCH 02/11] env_mmc.c: Make the non-redundant env_relocate_spec use malloc not stack
Tom Rini
trini at ti.com
Thu Sep 26 22:27:58 CEST 2013
Switch the case of non-redundant non-embedded environment to use malloc
to allocate buffers, rather than place them on the stack, like the
redundant case does.
Signed-off-by: Tom Rini <trini at ti.com>
---
common/env_mmc.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/common/env_mmc.c b/common/env_mmc.c
index 65aafa9..0ab11d3 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -274,11 +274,18 @@ err:
void env_relocate_spec(void)
{
#if !defined(ENV_IS_EMBEDDED)
- ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
+ env_t *ep;
u32 offset;
int ret;
+ ep = (env_t *)malloc(CONFIG_ENV_SIZE);
+ if (ep == NULL) {
+ puts("Can't allocate buffers for environment\n");
+ ret = 1;
+ goto err;
+ }
+
if (init_mmc_for_env(mmc)) {
ret = 1;
goto err;
@@ -289,12 +296,12 @@ void env_relocate_spec(void)
goto fini;
}
- if (read_env(mmc, CONFIG_ENV_SIZE, offset, buf)) {
+ if (read_env(mmc, CONFIG_ENV_SIZE, offset, ep)) {
ret = 1;
goto fini;
}
- env_import(buf, 1);
+ env_import((char *)ep, 1);
ret = 0;
fini:
@@ -302,6 +309,8 @@ fini:
err:
if (ret)
set_default_env(NULL);
+
+ free(ep);
#endif
}
#endif /* CONFIG_ENV_OFFSET_REDUND */
--
1.7.9.5
More information about the U-Boot
mailing list