public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* Found ecc verify bug in nand.c
@ 2002-08-16 21:13 Ken Offer
  2002-08-17  8:16 ` Thomas Gleixner
  0 siblings, 1 reply; 2+ messages in thread
From: Ken Offer @ 2002-08-16 21:13 UTC (permalink / raw)
  To: LinuxMTD

Hi all,

Using the cvs code from August 12th, I found a bug in nand.c 
that was causing a page write to fail ecc verify.  In nand.c in 
the function "nand_write_page" there is a line which reads:

    if ((this->data_buf[(oob_config.ecc_pos[i])] != 
ecc_code[i]) && ecc_code[i]) {

This is a compare to see if the ecc has changed.  Unfortunately, 
data_buf is UNSIGNED char and ecc_code is SIGNED char.  When 
compiling under gcc 2.95.3 on a powerpc system, the code ends up 
comparing two identical bytes and fails because one is 
sign-extended (example: comparing 0xc3 becomes "0xc3 == 
0xffffffc3").  I don't know if this makes a difference with the 
x86 compiler, but it does under powerpc.

Changing the local array "ecc_code" to type "u_char" resolves 
the problem.  Verified by running nandtest.

+-----------------------------------------------------------+
|  Ken Offer        koffer@arlut.utexas.edu         ARL:UT  |
|  Office: 512-835-3859                  Fax: 512-835-3259  |
+-----------------------------------------------------------+

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Found ecc verify bug in nand.c
  2002-08-16 21:13 Found ecc verify bug in nand.c Ken Offer
@ 2002-08-17  8:16 ` Thomas Gleixner
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2002-08-17  8:16 UTC (permalink / raw)
  To: Ken Offer; +Cc: LinuxMTD

On Fri, 2002-08-16 at 23:13, Ken Offer wrote:
> This is a compare to see if the ecc has changed.  Unfortunately, 
> data_buf is UNSIGNED char and ecc_code is SIGNED char.  When 
> compiling under gcc 2.95.3 on a powerpc system, the code ends up 
> comparing two identical bytes and fails because one is 
> sign-extended (example: comparing 0xc3 becomes "0xc3 == 
> 0xffffffc3").  I don't know if this makes a difference with the 
> x86 compiler, but it does under powerpc.
It's a problem on other arch's too. It did not happen to me, because I
don't use the NAND_WRITE_VERIFY paranoia check :)
Thanks, fixed in CVS

-- 
Thomas 
____________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: tglx@linutronix.de

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-08-17  8:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-16 21:13 Found ecc verify bug in nand.c Ken Offer
2002-08-17  8:16 ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox