[MTD] [NAND] Casting bug in nand_default_block_markbad
authorAndre Renaud <andre@bluewatersys.com>
Tue, 17 Apr 2007 17:50:59 +0000 (13:50 -0400)
committerDavid Woodhouse <dwmw2@infradead.org>
Tue, 17 Apr 2007 17:50:59 +0000 (13:50 -0400)
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@bluewatersys.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
drivers/mtd/nand/nand_base.c

index 5b96f1c5759f57806a62034c9b695ddcb56367b8..ab3b2d16cffe5ede269b143743bf71da7dd20f10 100644 (file)
@@ -350,7 +350,7 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
        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);