summaryrefslogtreecommitdiff
path: root/env
diff options
context:
space:
mode:
authorWeijie Gao <[email protected]>2025-05-06 15:15:01 +0800
committerTom Rini <[email protected]>2025-05-23 08:00:51 -0600
commit7c52bca8121fdd967edf24402590b8aacf4fd23a (patch)
tree02351d1f62544c4365e37c24025c83fa95fa21cb /env
parentdf5dcf7b7eb66f74262c5e501f813aac759557f2 (diff)
env: mtd: fix usability with NAND flashes
1. As this is for MTD-based devices, the Kconfig dependency should be MTD instead of only spi-nor flashes 2. Initialize saved_buf to avoid crash on free() 3. Remaining size should be set correctly to write_size Fixes: 03fb08d4aef (env: Introduce support for MTD) Signed-off-by: Weijie Gao <[email protected]> Reviewed-by: Christian Marangi <[email protected]>
Diffstat (limited to 'env')
-rw-r--r--env/Kconfig2
-rw-r--r--env/mtd.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/env/Kconfig b/env/Kconfig
index 9f5ec44601e..d7a7e81144b 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -389,7 +389,7 @@ config ENV_IS_IN_SPI_FLASH
config ENV_IS_IN_MTD
bool "Environment is in MTD flash"
- depends on !CHAIN_OF_TRUST && (SPI_FLASH || DM_SPI_FLASH)
+ depends on !CHAIN_OF_TRUST && MTD
default y if ARCH_AIROHA
help
Define this if you have a MTD Flash memory device which you
diff --git a/env/mtd.c b/env/mtd.c
index 721faebd8f2..d7ec30e183a 100644
--- a/env/mtd.c
+++ b/env/mtd.c
@@ -32,7 +32,7 @@ static int setup_mtd_device(struct mtd_info **mtd_env)
static int env_mtd_save(void)
{
- char *saved_buf, *write_buf, *tmp;
+ char *saved_buf = NULL, *write_buf, *tmp;
struct erase_info ei = { };
struct mtd_info *mtd_env;
u32 sect_size, sect_num;
@@ -105,7 +105,7 @@ static int env_mtd_save(void)
}
offset = CONFIG_ENV_OFFSET;
- remaining = sect_size;
+ remaining = write_size;
tmp = write_buf;
puts("Writing to MTD...");