From: Christian Marangi <ansuelsmth@gmail.com>
To: Weijie Gao <weijie.gao@mediatek.com>
Cc: u-boot@lists.denx.de,
GSS_MTK_Uboot_upstream <GSS_MTK_Uboot_upstream@mediatek.com>,
Joe Hershberger <joe.hershberger@ni.com>,
Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH] env: mtd: fix usability with NAND flashes
Date: Tue, 6 May 2025 13:44:11 +0200 [thread overview]
Message-ID: <6819f60e.050a0220.2e9b7e.67d0@mx.google.com> (raw)
In-Reply-To: <20250506071501.28253-1-weijie.gao@mediatek.com>
On Tue, May 06, 2025 at 03:15:01PM +0800, Weijie Gao wrote:
> 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 shoule 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>
> ---
> env/Kconfig | 2 +-
> env/mtd.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/env/Kconfig b/env/Kconfig
> index 1e876c6fa85..ce869a24d46 100644
> --- a/env/Kconfig
> +++ b/env/Kconfig
> @@ -404,7 +404,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...");
> --
> 2.34.1
>
--
Ansuel
next prev parent reply other threads:[~2025-05-06 11:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 7:15 [PATCH] env: mtd: fix usability with NAND flashes Weijie Gao
2025-05-06 11:44 ` Christian Marangi [this message]
2025-05-23 14:01 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6819f60e.050a0220.2e9b7e.67d0@mx.google.com \
--to=ansuelsmth@gmail.com \
--cc=GSS_MTK_Uboot_upstream@mediatek.com \
--cc=joe.hershberger@ni.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=weijie.gao@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox