Patchwork Missing offset increment in scan_read_raw_oob()

login
register
mail settings
Submitter Dmitry Maluka
Date May 11, 2012, 5:51 p.m.
Message ID <4FAD51B7.6010303@adbglobal.com>
Download mbox | patch
Permalink /patch/158562/
State New
Headers show

Comments

Dmitry Maluka - May 11, 2012, 5:51 p.m.
It seems there is a bug in scan_read_raw_oob() in nand_bbt.c which
should cause wrong functioning of NAND_BBT_SCANALLPAGES option.

Possible fix (relies on offs passed page-aligned):

 }
Artem Bityutskiy - May 15, 2012, 6:57 a.m.
On Fri, 2012-05-11 at 20:51 +0300, Dmitry Maluka wrote:
> It seems there is a bug in scan_read_raw_oob() in nand_bbt.c which
> should cause wrong functioning of NAND_BBT_SCANALLPAGES option.
> 
> Possible fix (relies on offs passed page-aligned):
> 
> --- a/drivers/mtd/nand/nand_bbt.c
> +++ b/drivers/mtd/nand/nand_bbt.c
> @@ -324,6 +324,7 @@ static int scan_read_raw_oob(struct mtd_info *mtd,
> uint8_t *buf, loff_t offs,
>  
>                 buf += mtd->oobsize + mtd->writesize;
>                 len -= mtd->writesize;
> +               offs += mtd->writesize;
>         }
>         return 0;
>  }

Looks like a correct fix. Did you encounter a real bug and then spot
this issue, or you spot it by reading the code?
Artem Bityutskiy - May 15, 2012, 7:03 a.m.
On Fri, 2012-05-11 at 20:51 +0300, Dmitry Maluka wrote:
> It seems there is a bug in scan_read_raw_oob() in nand_bbt.c which
> should cause wrong functioning of NAND_BBT_SCANALLPAGES option.
> 
> Possible fix (relies on offs passed page-aligned):

I pushed it to l2-mtd.git, but please, tell how you found this issue.
Also you did not provide signed-off-by - can I add this:

Signed-off-by: Dmitry Maluka <D.Maluka@adbglobal.com>

?

Also note, the patch was line-wrapped and did not apply, so I had to
amend it.
Dmitry Maluka - May 15, 2012, 8:04 a.m.
On 05/15/2012 10:03 AM, Artem Bityutskiy wrote:
> I pushed it to l2-mtd.git, but please, tell how you found this issue.

Just by reading the code. I do not use NAND_BBT_SCANALLPAGES so I think
I couldn't face this bug.

> Also you did not provide signed-off-by - can I add this:
> 
> Signed-off-by: Dmitry Maluka <D.Maluka@adbglobal.com>
> 
> ?
> 
> Also note, the patch was line-wrapped and did not apply, so I had to
> amend it.

Ok, no problem.

Patch

--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -324,6 +324,7 @@  static int scan_read_raw_oob(struct mtd_info *mtd,
uint8_t *buf, loff_t offs,
 
                buf += mtd->oobsize + mtd->writesize;
                len -= mtd->writesize;
+               offs += mtd->writesize;
        }
        return 0;