[PATCH] mtd/mxc_nand: fix read past buffer end

Baruch Siach baruch at tkos.co.il
Wed Mar 2 10:06:50 EST 2011


Hi Sascha,

On Wed, Mar 02, 2011 at 04:02:35PM +0100, Sascha Hauer wrote:
> On Wed, Mar 02, 2011 at 04:47:55PM +0200, Baruch Siach wrote:
> > Signed-off-by: Baruch Siach <baruch at tkos.co.il>
> > ---
> >  drivers/mtd/nand/mxc_nand.c |    4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> Looks good to me. Did you stumble upon this by accident or did something
> break? If yes, would be good to have it in the commit log.

I found it by looking at the code. This doesn't fix my actual problem (wrong 
oob read and/or write with flash of page size 4K+218).

> Otherwise:
> 
> Acked-by: Sascha hauer <s.hauer at pengutronix.de>

Thanks,
baruch

> > diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
> > index 7b33811..466d7a9 100644
> > --- a/drivers/mtd/nand/mxc_nand.c
> > +++ b/drivers/mtd/nand/mxc_nand.c
> > @@ -641,9 +641,9 @@ static void mxc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
> >  
> >  	n = min(n, len);
> >  
> > -	memcpy(buf, host->data_buf + col, len);
> > +	memcpy(buf, host->data_buf + col, n);
> >  
> > -	host->buf_start += len;
> > +	host->buf_start += n;
> >  }
> >  
> >  /* Used by the upper layer to verify the data in NAND Flash
> > -- 
> > 1.7.2.3

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -



More information about the linux-mtd mailing list