diff options
author | Weijie Gao <weijie.gao@mediatek.com> | 2025-05-06 15:15:01 +0800 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2025-05-23 08:00:51 -0600 |
commit | 7c52bca8121fdd967edf24402590b8aacf4fd23a (patch) | |
tree | 02351d1f62544c4365e37c24025c83fa95fa21cb /env/mtd.c | |
parent | df5dcf7b7eb66f74262c5e501f813aac759557f2 (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 <weijie.gao@mediatek.com>
Reviewed-by: Christian Marangi <ansuelsmth@gmail.com>
Diffstat (limited to 'env/mtd.c')
-rw-r--r-- | env/mtd.c | 4 |
1 files changed, 2 insertions, 2 deletions
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..."); |