aboutsummaryrefslogtreecommitdiff
path: root/env
diff options
context:
space:
mode:
authorRalph Siemsen <ralph.siemsen@linaro.org>2024-01-19 16:32:17 -0500
committerTom Rini <trini@konsulko.com>2024-01-29 14:52:23 -0500
commit04add62e8cf1209ca21ddfa13346d9ddcc6126fb (patch)
tree0c6e1b2f7bd75ae387275da452d549be107a93dd /env
parentca6d60df2f3616f1817951621aa46023737ec711 (diff)
downloadu-boot-04add62e8cf1209ca21ddfa13346d9ddcc6126fb.zip
u-boot-04add62e8cf1209ca21ddfa13346d9ddcc6126fb.tar.gz
u-boot-04add62e8cf1209ca21ddfa13346d9ddcc6126fb.tar.bz2
env: sf: report malloc error to caller
In the non-redundant code for env_sf_save(), a failure to malloc() the temporary buffer produces the following output: Saving Environment to SPIFlash... OK This is misleading as the flash has neither been erased nor written. Fix it to return an error to the caller, so the output will be: Saving Environment to SPIFlash... Failed (-12) Note that there is another copy of env_sf_save() in the same file, for handling redundant environment, and it already has the same logic. Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
Diffstat (limited to 'env')
-rw-r--r--env/sf.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/env/sf.c b/env/sf.c
index a425ecc..8f5c03b 100644
--- a/env/sf.c
+++ b/env/sf.c
@@ -210,8 +210,10 @@ static int env_sf_save(void)
saved_size = sect_size - CONFIG_ENV_SIZE;
saved_offset = CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE;
saved_buffer = malloc(saved_size);
- if (!saved_buffer)
+ if (!saved_buffer) {
+ ret = -ENOMEM;
goto done;
+ }
ret = spi_flash_read(env_flash, saved_offset,
saved_size, saved_buffer);