Files
xiaomi-ax3600/package/boot/uboot-mediatek/patches/130-02-env-mtd-initialize-saved_buf-pointer.patch
Shiji Yang 8a63382018 uboot-mediatek: fix various environment errors on u-boot v2025.07
Fix the crash and warnings for the newly introduced env on mtd
implementation. Also backport an out-of-bound access fix for the
"askenv" command.

Fixes: 41a9c9de66 ("uboot-mediatek: update to v2025.07")
Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
2025-07-28 15:07:35 +01:00

26 lines
751 B
Diff

From 0ef932f509fd9f9215af2ea4ca2919d3285ddf60 Mon Sep 17 00:00:00 2001
From: Shiji Yang <yangshiji66@outlook.com>
Date: Thu, 24 Jul 2025 07:50:40 +0800
Subject: [PATCH 2/2] env: mtd: initialize saved_buf pointer
When sect_size is greater than 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@outlook.com>
---
env/mtd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- 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;