linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: spi-devel-general@lists.sourceforge.net, linux-sh@vger.kernel.org
Subject: Re: [PATCH 3/3] SPI: spi_sh_msiof: fix wrong address calculation, which leads to an Oops
Date: Fri, 21 Jan 2011 09:27:43 -0700	[thread overview]
Message-ID: <20110121162743.GA7477@angua.secretlab.ca> (raw)
In-Reply-To: <Pine.LNX.4.64.1101211655550.18867@axis700.grange>

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

  reply	other threads:[~2011-01-21 16:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2011-01-22  3:26   ` Paul Mundt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110121162743.GA7477@angua.secretlab.ca \
    --to=grant.likely@secretlab.ca \
    --cc=g.liakhovetski@gmx.de \
    --cc=linux-sh@vger.kernel.org \
    --cc=spi-devel-general@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).