Patchwork mtd/mxc_nand: fix read past buffer end

login
register
mail settings
Submitter Baruch Siach
Date March 2, 2011, 2:47 p.m.
Message ID <2edd0d1419770540f85178a1f29cd80fccf11e88.1299077237.git.baruch@tkos.co.il>
Download mbox | patch
Permalink /patch/85089/
State New
Headers show

Comments

Baruch Siach - March 2, 2011, 2:47 p.m.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 drivers/mtd/nand/mxc_nand.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Sascha Hauer - March 2, 2011, 3:02 p.m.
On Wed, Mar 02, 2011 at 04:47:55PM +0200, Baruch Siach wrote:
> Signed-off-by: Baruch Siach <baruch@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.

Otherwise:

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


> 
> 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
> 
>
Baruch Siach - March 2, 2011, 3:06 p.m.
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@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@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
Artem Bityutskiy - March 7, 2011, 9:29 a.m.
On Wed, 2011-03-02 at 16:47 +0200, Baruch Siach wrote:
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>  drivers/mtd/nand/mxc_nand.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

Pushed to l2-mtd-2.6.git, thank you!

Patch

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