[PATCH] [MTD] Casting bug in nand_default_block_markbad

Andre Renaud andre at bluewatersys.com
Tue Apr 10 23:14:24 EDT 2007


There is a slight bug in nand_default_block_markbad, where the offset is
cast to an integer, prior to being shifted. This means that on large
offsets, it is incorrectly doing a signed shift & losing bits. Fixed
this by doing the cast after the shift (as is done elsewhere in the code).

Signed-off-by: Andre Renaud <andre at bluewatersys.com>

Index: drivers/mtd/nand/nand_base.c
===================================================================
--- drivers/mtd/nand/nand_base.c        (revision 957)
+++ drivers/mtd/nand/nand_base.c        (working copy)
@@ -355,7 +355,7 @@
        int block, ret;

        /* Get block number */
-       block = ((int)ofs) >> chip->bbt_erase_shift;
+       block = (int)(ofs >> chip->bbt_erase_shift);
        if (chip->bbt)
                chip->bbt[block >> 2] |= 0x01 << ((block & 0x03) << 1);

-- 
Bluewater Systems Ltd - ARM Technology Solutions Centre

       Andre Renaud                             Bluewater Systems Ltd
Phone: +64 3 3779127 (Aus 1 800 148 751)        Level 17, 119 Armagh St
Fax:   +64 3 3779135                            PO Box 13889
Email: arenaud at bluewatersys.com                 Christchurch
Web:   http://www.bluewatersys.com              New Zealand




More information about the linux-mtd mailing list