lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100122220410.GN12439@broadcom.com>
Date:	Fri, 22 Jan 2010 14:04:10 -0800
From:	"Leo (Hao) Chen" <leochen@...adcom.com>
To:	"Roel Kluin" <roel.kluin@...il.com>
cc:	"Scott Branden" <sbranden@...adcom.com>,
	"linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>,
	"Andrew Morton" <akpm@...ux-foundation.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mtd: hot spin and code duplication in
 nand_bcm_umi_bch_read_oobEcc()

Thanks for identifying the NumToRead bug.
Tested on board. Works.

Acked-by: Leo Chen <leochen@...adcom.com>

On Fri, Jan 22, 2010 at 01:22:52PM -0800, Roel Kluin wrote:
> In the branch where pagesize equalled NAND_DATA_ACCESS_SIZE, NumToRead
> wasn't decremented in the `while (numToRead > 11)' loop.
> Also the first and last while loops were duplicated in both branches.
> 
> Signed-off-by: Roel Kluin <roel.kluin@...il.com>
> ---
>  drivers/mtd/nand/nand_bcm_umi.h |   71 ++++++++++++++-------------------------
>  1 files changed, 25 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_bcm_umi.h b/drivers/mtd/nand/nand_bcm_umi.h
> index 7cec2cd..198b304 100644
> --- a/drivers/mtd/nand/nand_bcm_umi.h
> +++ b/drivers/mtd/nand/nand_bcm_umi.h
> @@ -167,18 +167,27 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
>  	int numToRead = 16;	/* There are 16 bytes per sector in the OOB */
>  
>  	/* ECC is already paused when this function is called */
> +	if (pageSize != NAND_DATA_ACCESS_SIZE) {
> +		/* skip BI */
> +#if defined(__KERNEL__) && !defined(STANDALONE)
> +		*oobp++ = REG_NAND_DATA8;
> +#else
> +		REG_NAND_DATA8;
> +#endif
> +		numToRead--;
> +	}
>  
> -	if (pageSize == NAND_DATA_ACCESS_SIZE) {
> -		while (numToRead > numEccBytes) {
> -			/* skip free oob region */
> +	while (numToRead > numEccBytes) {
> +		/* skip free oob region */
>  #if defined(__KERNEL__) && !defined(STANDALONE)
> -			*oobp++ = REG_NAND_DATA8;
> +		*oobp++ = REG_NAND_DATA8;
>  #else
> -			REG_NAND_DATA8;
> +		REG_NAND_DATA8;
>  #endif
> -			numToRead--;
> -		}
> +		numToRead--;
> +	}
>  
> +	if (pageSize == NAND_DATA_ACCESS_SIZE) {
>  		/* read ECC bytes before BI */
>  		nand_bcm_umi_bch_resume_read_ecc_calc();
>  
> @@ -190,6 +199,7 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
>  #else
>  			eccCalc[eccPos++] = REG_NAND_DATA8;
>  #endif
> +			numToRead--;
>  		}
>  
>  		nand_bcm_umi_bch_pause_read_ecc_calc();
> @@ -204,49 +214,18 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
>  			numToRead--;
>  		}
>  
> -		/* read ECC bytes */
> -		nand_bcm_umi_bch_resume_read_ecc_calc();
> -		while (numToRead) {
> -#if defined(__KERNEL__) && !defined(STANDALONE)
> -			*oobp = REG_NAND_DATA8;
> -			eccCalc[eccPos++] = *oobp;
> -			oobp++;
> -#else
> -			eccCalc[eccPos++] = REG_NAND_DATA8;
> -#endif
> -			numToRead--;
> -		}
> -	} else {
> -		/* skip BI */
> +	}
> +	/* read ECC bytes */
> +	nand_bcm_umi_bch_resume_read_ecc_calc();
> +	while (numToRead) {
>  #if defined(__KERNEL__) && !defined(STANDALONE)
> -		*oobp++ = REG_NAND_DATA8;
> +		*oobp = REG_NAND_DATA8;
> +		eccCalc[eccPos++] = *oobp;
> +		oobp++;
>  #else
> -		REG_NAND_DATA8;
> +		eccCalc[eccPos++] = REG_NAND_DATA8;
>  #endif
>  		numToRead--;
> -
> -		while (numToRead > numEccBytes) {
> -			/* skip free oob region */
> -#if defined(__KERNEL__) && !defined(STANDALONE)
> -			*oobp++ = REG_NAND_DATA8;
> -#else
> -			REG_NAND_DATA8;
> -#endif
> -			numToRead--;
> -		}
> -
> -		/* read ECC bytes */
> -		nand_bcm_umi_bch_resume_read_ecc_calc();
> -		while (numToRead) {
> -#if defined(__KERNEL__) && !defined(STANDALONE)
> -			*oobp = REG_NAND_DATA8;
> -			eccCalc[eccPos++] = *oobp;
> -			oobp++;
> -#else
> -			eccCalc[eccPos++] = REG_NAND_DATA8;
> -#endif
> -			numToRead--;
> -		}
>  	}
>  }
>  
> 

-- 

Leo Hao Chen

------------------------
Life is short, run long.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ