public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] [MTD] Casting bug in nand_default_block_markbad
@ 2007-04-11  3:14 Andre Renaud
  2007-04-14  9:56 ` Thomas Gleixner
  0 siblings, 1 reply; 2+ messages in thread
From: Andre Renaud @ 2007-04-11  3:14 UTC (permalink / raw)
  To: linux-mtd

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>

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@bluewatersys.com                 Christchurch
Web:   http://www.bluewatersys.com              New Zealand

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

* Re: [PATCH] [MTD] Casting bug in nand_default_block_markbad
  2007-04-11  3:14 [PATCH] [MTD] Casting bug in nand_default_block_markbad Andre Renaud
@ 2007-04-14  9:56 ` Thomas Gleixner
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2007-04-14  9:56 UTC (permalink / raw)
  To: Andre Renaud; +Cc: linux-mtd

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

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

end of thread, other threads:[~2007-04-14  9:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-11  3:14 [PATCH] [MTD] Casting bug in nand_default_block_markbad Andre Renaud
2007-04-14  9:56 ` Thomas Gleixner

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