[PATCH 2/2] env: mtd: initialize saved_buf pointer
Shiji Yang
yangshiji66 at outlook.com
Fri Jul 25 02:20:45 CEST 2025
When sect_size is greater than the CONFIG_ENV_SIZE, this wild
pointer will cause CPU halt or system crash.
Fixes: 03fb08d4aef8 ("env: Introduce support for MTD")
Signed-off-by: Shiji Yang <yangshiji66 at outlook.com>
---
env/mtd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/env/mtd.c b/env/mtd.c
index ad263ed4b29..b26ee80985a 100644
--- a/env/mtd.c
+++ b/env/mtd.c
@@ -201,7 +201,7 @@ static int env_mtd_erase(void)
{
struct mtd_info *mtd_env;
u32 sect_size, sect_num;
- char *saved_buf, *tmp;
+ char *saved_buf = NULL, *tmp;
struct erase_info ei;
size_t ret_len;
int remaining;
--
2.50.0
More information about the U-Boot
mailing list