From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Rini Date: Thu, 26 Sep 2013 16:27:58 -0400 Subject: [U-Boot] [PATCH 02/11] env_mmc.c: Make the non-redundant env_relocate_spec use malloc not stack In-Reply-To: <1380227287-26057-1-git-send-email-trini@ti.com> References: <1380227287-26057-1-git-send-email-trini@ti.com> Message-ID: <1380227287-26057-3-git-send-email-trini@ti.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- 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