[PATCH] [MTD] Casting bug in nand_default_block_markbad

Thomas Gleixner tglx at linutronix.de
Sat Apr 14 05:56:03 EDT 2007


On Wed, 2007-04-11 at 15:14 +1200, Andre Renaud wrote:
> 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)

Please provide patches which can be applied with -p1, i.e. do the diff
one directory level up

> @@ -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);

Also your patch is whitespace damaged and does not apply.
There is some HOWTO submit patches with Thunderbird somewhere in the
net.

I fix that up manually.

Thanks,

	tglx






More information about the linux-mtd mailing list