From patchwork Wed May 18 13:21:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Hobi X-Patchwork-Id: 96170 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 05BA9B6F69 for ; Wed, 18 May 2011 23:51:25 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B245928086; Wed, 18 May 2011 15:51:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LGhAGF9bFqhO; Wed, 18 May 2011 15:51:22 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 68BF828080; Wed, 18 May 2011 15:51:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6C29928080 for ; Wed, 18 May 2011 15:51:18 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5qS+G5RqFvRh for ; Wed, 18 May 2011 15:51:17 +0200 (CEST) X-Greylist: delayed 1801 seconds by postgrey-1.27 at theia; Wed, 18 May 2011 15:51:15 CEST X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail.schmid-telecom.ch (mail.schmid-telecom.ch [213.173.183.22]) by theia.denx.de (Postfix) with ESMTPS id 06B902807E for ; Wed, 18 May 2011 15:51:15 +0200 (CEST) Received: from szexchange.schmid-telecom.com [10.100.100.66] by mail.schmid-telecom.ch with XWall v3.40 ; Wed, 18 May 2011 15:21:13 +0200 Received: from hal.schmid-telecom.com ([10.100.100.31]) by szexchange.schmid-telecom.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 18 May 2011 15:21:12 +0200 From: Daniel Hobi To: u-boot@lists.denx.de Date: Wed, 18 May 2011 15:21:08 +0200 Message-Id: <1305724868-3827-1-git-send-email-daniel.hobi@schmid-telecom.ch> X-Mailer: git-send-email 1.7.3.5 X-OriginalArrivalTime: 18 May 2011 13:21:12.0665 (UTC) FILETIME=[75570C90:01CC155E] Cc: Scott Wood Subject: [U-Boot] [PATCH] [FIX] env_nand: zero-initialize variable nand_erase_options X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 --- common/env_nand.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-) diff --git a/common/env_nand.c b/common/env_nand.c index 980425a..14446a6 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -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)