All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] SPI: spi_sh_msiof: fix wrong address calculation, which
@ 2011-01-21 15:56 ` Guennadi Liakhovetski
  0 siblings, 0 replies; 6+ messages in thread
From: Guennadi Liakhovetski @ 2011-01-21 15:56 UTC (permalink / raw)
  To: spi-devel-general; +Cc: linux-sh

NULL + <small offset> != NULL, but reading from that <small offset> address
is usually not a very good idea and often leads to problems, like kernel
Oopses in this case, easily reproducible by writing to an SD-card, used in
SPI mode.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/spi/spi_sh_msiof.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi_sh_msiof.c b/drivers/spi/spi_sh_msiof.c
index 658bd05..6d30829 100644
--- a/drivers/spi/spi_sh_msiof.c
+++ b/drivers/spi/spi_sh_msiof.c
@@ -568,9 +568,11 @@ static int sh_msiof_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
 	bytes_done = 0;
 
 	while (bytes_done < t->len) {
+		void *rx_buf = t->rx_buf ? t->rx_buf + bytes_done : NULL;
+		const void *tx_buf = t->tx_buf ? t->tx_buf + bytes_done : NULL;
 		n = sh_msiof_spi_txrx_once(p, tx_fifo, rx_fifo,
-					   t->tx_buf + bytes_done,
-					   t->rx_buf + bytes_done,
+					   tx_buf,
+					   rx_buf,
 					   words, bits);
 		if (n < 0)
 			break;
-- 
1.7.2.3


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

* [PATCH 3/3] SPI: spi_sh_msiof: fix wrong address calculation, which leads to an Oops
@ 2011-01-21 15:56 ` Guennadi Liakhovetski
  0 siblings, 0 replies; 6+ messages in thread
From: Guennadi Liakhovetski @ 2011-01-21 15:56 UTC (permalink / raw)
  To: spi-devel-general; +Cc: linux-sh

NULL + <small offset> != NULL, but reading from that <small offset> address
is usually not a very good idea and often leads to problems, like kernel
Oopses in this case, easily reproducible by writing to an SD-card, used in
SPI mode.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/spi/spi_sh_msiof.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi_sh_msiof.c b/drivers/spi/spi_sh_msiof.c
index 658bd05..6d30829 100644
--- a/drivers/spi/spi_sh_msiof.c
+++ b/drivers/spi/spi_sh_msiof.c
@@ -568,9 +568,11 @@ static int sh_msiof_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
 	bytes_done = 0;
 
 	while (bytes_done < t->len) {
+		void *rx_buf = t->rx_buf ? t->rx_buf + bytes_done : NULL;
+		const void *tx_buf = t->tx_buf ? t->tx_buf + bytes_done : NULL;
 		n = sh_msiof_spi_txrx_once(p, tx_fifo, rx_fifo,
-					   t->tx_buf + bytes_done,
-					   t->rx_buf + bytes_done,
+					   tx_buf,
+					   rx_buf,
 					   words, bits);
 		if (n < 0)
 			break;
-- 
1.7.2.3


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

* Re: [PATCH 3/3] SPI: spi_sh_msiof: fix wrong address calculation,
  2011-01-21 15:56 ` [PATCH 3/3] SPI: spi_sh_msiof: fix wrong address calculation, which leads to an Oops Guennadi Liakhovetski
@ 2011-01-21 16:27   ` Grant Likely
  -1 siblings, 0 replies; 6+ messages in thread
From: Grant Likely @ 2011-01-21 16:27 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: spi-devel-general, linux-sh

On Fri, Jan 21, 2011 at 04:56:47PM +0100, Guennadi Liakhovetski wrote:
> NULL + <small offset> != NULL, but reading from that <small offset> address
> is usually not a very good idea and often leads to problems, like kernel
> Oopses in this case, easily reproducible by writing to an SD-card, used in
> SPI mode.
> 
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

Applied, thanks.  Since this is an oops fix, I'll push this one to
Linus before the next -rc.  The other two can go into linux-next for
2.6.39.

g.

> ---
>  drivers/spi/spi_sh_msiof.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/spi_sh_msiof.c b/drivers/spi/spi_sh_msiof.c
> index 658bd05..6d30829 100644
> --- a/drivers/spi/spi_sh_msiof.c
> +++ b/drivers/spi/spi_sh_msiof.c
> @@ -568,9 +568,11 @@ static int sh_msiof_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
>  	bytes_done = 0;
>  
>  	while (bytes_done < t->len) {
> +		void *rx_buf = t->rx_buf ? t->rx_buf + bytes_done : NULL;
> +		const void *tx_buf = t->tx_buf ? t->tx_buf + bytes_done : NULL;
>  		n = sh_msiof_spi_txrx_once(p, tx_fifo, rx_fifo,
> -					   t->tx_buf + bytes_done,
> -					   t->rx_buf + bytes_done,
> +					   tx_buf,
> +					   rx_buf,
>  					   words, bits);
>  		if (n < 0)
>  			break;
> -- 
> 1.7.2.3
> 
> 
> ------------------------------------------------------------------------------
> Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
> Finally, a world-class log management solution at an even better price-free!
> Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
> February 28th, so secure your free ArcSight Logger TODAY! 
> http://p.sf.net/sfu/arcsight-sfd2d
> _______________________________________________
> spi-devel-general mailing list
> spi-devel-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general

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

* Re: [PATCH 3/3] SPI: spi_sh_msiof: fix wrong address calculation, which leads to an Oops
@ 2011-01-21 16:27   ` Grant Likely
  0 siblings, 0 replies; 6+ messages in thread
From: Grant Likely @ 2011-01-21 16:27 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: spi-devel-general, linux-sh

On Fri, Jan 21, 2011 at 04:56:47PM +0100, Guennadi Liakhovetski wrote:
> NULL + <small offset> != NULL, but reading from that <small offset> address
> is usually not a very good idea and often leads to problems, like kernel
> Oopses in this case, easily reproducible by writing to an SD-card, used in
> SPI mode.
> 
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

Applied, thanks.  Since this is an oops fix, I'll push this one to
Linus before the next -rc.  The other two can go into linux-next for
2.6.39.

g.

> ---
>  drivers/spi/spi_sh_msiof.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/spi_sh_msiof.c b/drivers/spi/spi_sh_msiof.c
> index 658bd05..6d30829 100644
> --- a/drivers/spi/spi_sh_msiof.c
> +++ b/drivers/spi/spi_sh_msiof.c
> @@ -568,9 +568,11 @@ static int sh_msiof_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
>  	bytes_done = 0;
>  
>  	while (bytes_done < t->len) {
> +		void *rx_buf = t->rx_buf ? t->rx_buf + bytes_done : NULL;
> +		const void *tx_buf = t->tx_buf ? t->tx_buf + bytes_done : NULL;
>  		n = sh_msiof_spi_txrx_once(p, tx_fifo, rx_fifo,
> -					   t->tx_buf + bytes_done,
> -					   t->rx_buf + bytes_done,
> +					   tx_buf,
> +					   rx_buf,
>  					   words, bits);
>  		if (n < 0)
>  			break;
> -- 
> 1.7.2.3
> 
> 
> ------------------------------------------------------------------------------
> Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
> Finally, a world-class log management solution at an even better price-free!
> Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
> February 28th, so secure your free ArcSight Logger TODAY! 
> http://p.sf.net/sfu/arcsight-sfd2d
> _______________________________________________
> spi-devel-general mailing list
> spi-devel-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general

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

* Re: [PATCH 3/3] SPI: spi_sh_msiof: fix wrong address calculation, which leads to an Oops
  2011-01-21 16:27   ` [PATCH 3/3] SPI: spi_sh_msiof: fix wrong address calculation, which leads to an Oops Grant Likely
@ 2011-01-22  3:26     ` Paul Mundt
  -1 siblings, 0 replies; 6+ messages in thread
From: Paul Mundt @ 2011-01-22  3:26 UTC (permalink / raw)
  To: Grant Likely; +Cc: Guennadi Liakhovetski, spi-devel-general, linux-sh

On Fri, Jan 21, 2011 at 09:27:43AM -0700, Grant Likely wrote:
> On Fri, Jan 21, 2011 at 04:56:47PM +0100, Guennadi Liakhovetski wrote:
> > NULL + <small offset> != NULL, but reading from that <small offset> address
> > is usually not a very good idea and often leads to problems, like kernel
> > Oopses in this case, easily reproducible by writing to an SD-card, used in
> > SPI mode.
> > 
> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> 
> Applied, thanks.  Since this is an oops fix, I'll push this one to
> Linus before the next -rc.  The other two can go into linux-next for
> 2.6.39.
> 
I haven't been following too closely, but this may also be a good -stable
candidate.

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

* Re: [PATCH 3/3] SPI: spi_sh_msiof: fix wrong address calculation, which leads to an Oops
@ 2011-01-22  3:26     ` Paul Mundt
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Mundt @ 2011-01-22  3:26 UTC (permalink / raw)
  To: Grant Likely; +Cc: Guennadi Liakhovetski, spi-devel-general, linux-sh

On Fri, Jan 21, 2011 at 09:27:43AM -0700, Grant Likely wrote:
> On Fri, Jan 21, 2011 at 04:56:47PM +0100, Guennadi Liakhovetski wrote:
> > NULL + <small offset> != NULL, but reading from that <small offset> address
> > is usually not a very good idea and often leads to problems, like kernel
> > Oopses in this case, easily reproducible by writing to an SD-card, used in
> > SPI mode.
> > 
> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> 
> Applied, thanks.  Since this is an oops fix, I'll push this one to
> Linus before the next -rc.  The other two can go into linux-next for
> 2.6.39.
> 
I haven't been following too closely, but this may also be a good -stable
candidate.

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

end of thread, other threads:[~2011-01-22  3:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-21 15:56 [PATCH 3/3] SPI: spi_sh_msiof: fix wrong address calculation, which Guennadi Liakhovetski
2011-01-21 15:56 ` [PATCH 3/3] SPI: spi_sh_msiof: fix wrong address calculation, which leads to an Oops Guennadi Liakhovetski
2011-01-21 16:27 ` [PATCH 3/3] SPI: spi_sh_msiof: fix wrong address calculation, Grant Likely
2011-01-21 16:27   ` [PATCH 3/3] SPI: spi_sh_msiof: fix wrong address calculation, which leads to an Oops Grant Likely
2011-01-22  3:26   ` Paul Mundt
2011-01-22  3:26     ` Paul Mundt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.