Skip to content

Commit

Permalink
[MTD] [NAND] Casting bug in nand_default_block_markbad
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andre Renaud authored and David Woodhouse committed Apr 17, 2007
1 parent 340ea37 commit 4226b51
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/mtd/nand/nand_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 4226b51

Please sign in to comment.