env_nand: zero-initialize variable nand_erase_options
authorDaniel Hobi <daniel.hobi@schmid-telecom.ch>
Wed, 18 May 2011 13:21:08 +0000 (15:21 +0200)
committerScott Wood <scottwood@freescale.com>
Tue, 24 May 2011 21:08:44 +0000 (16:08 -0500)
Commit 30486322 (nand erase: .spread, .part, .chip subcommands)
added a new field to struct nand_erase_options, but forgot to
update common/env_nand.c.

Depending on the stack state and bad block distribution, saveenv()
can thus erase more than CONFIG_ENV_RANGE bytes which may corrupt
the following NAND sectors/partitions.

Signed-off-by: Daniel Hobi <daniel.hobi@schmid-telecom.ch>
Signed-off-by: Scott Wood <scottwood@freescale.com>
common/env_nand.c

index 980425a8ee8df5d4592cf25a53170dbdd2b8813e..14446a6a5793ce0d37016d7a883445815517d479 100644 (file)
@@ -193,10 +193,8 @@ int saveenv(void)
        int     ret = 0;
        nand_erase_options_t nand_erase_options;
 
+       memset(&nand_erase_options, 0, sizeof(nand_erase_options));
        nand_erase_options.length = CONFIG_ENV_RANGE;
-       nand_erase_options.quiet = 0;
-       nand_erase_options.jffs2 = 0;
-       nand_erase_options.scrub = 0;
 
        if (CONFIG_ENV_RANGE < CONFIG_ENV_SIZE)
                return 1;
@@ -249,10 +247,8 @@ int saveenv(void)
        char    *res;
        nand_erase_options_t nand_erase_options;
 
+       memset(&nand_erase_options, 0, sizeof(nand_erase_options));
        nand_erase_options.length = CONFIG_ENV_RANGE;
-       nand_erase_options.quiet = 0;
-       nand_erase_options.jffs2 = 0;
-       nand_erase_options.scrub = 0;
        nand_erase_options.offset = CONFIG_ENV_OFFSET;
 
        if (CONFIG_ENV_RANGE < CONFIG_ENV_SIZE)