diff options
| author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2011-01-21 10:56:47 -0500 |
|---|---|---|
| committer | Grant Likely <grant.likely@secretlab.ca> | 2011-01-21 11:26:24 -0500 |
| commit | 8a6afb9a950de01457a4267bcbe3292e56412326 (patch) | |
| tree | 0db7d430e83675414aa97b23b1eb60726a59486d | |
| parent | c56eb8fb6dccb83d9fe62fd4dc00c834de9bc470 (diff) | |
spi/spi_sh_msiof: fix wrong address calculation, which leads to an Oops
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>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
| -rw-r--r-- | 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 56f60c8ea0a..2c665fceaac 100644 --- a/drivers/spi/spi_sh_msiof.c +++ b/drivers/spi/spi_sh_msiof.c | |||
| @@ -509,9 +509,11 @@ static int sh_msiof_spi_txrx(struct spi_device *spi, struct spi_transfer *t) | |||
| 509 | bytes_done = 0; | 509 | bytes_done = 0; |
| 510 | 510 | ||
| 511 | while (bytes_done < t->len) { | 511 | while (bytes_done < t->len) { |
| 512 | void *rx_buf = t->rx_buf ? t->rx_buf + bytes_done : NULL; | ||
| 513 | const void *tx_buf = t->tx_buf ? t->tx_buf + bytes_done : NULL; | ||
| 512 | n = sh_msiof_spi_txrx_once(p, tx_fifo, rx_fifo, | 514 | n = sh_msiof_spi_txrx_once(p, tx_fifo, rx_fifo, |
| 513 | t->tx_buf + bytes_done, | 515 | tx_buf, |
| 514 | t->rx_buf + bytes_done, | 516 | rx_buf, |
| 515 | words, bits); | 517 | words, bits); |
| 516 | if (n < 0) | 518 | if (n < 0) |
| 517 | break; | 519 | break; |
