Skip to content

Commit

Permalink
spi/spi_sh_msiof: fix wrong address calculation, which leads to an Oops
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Guennadi Liakhovetski authored and Grant Likely committed Jan 21, 2011
1 parent c56eb8f commit 8a6afb9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/spi/spi_sh_msiof.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,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;
Expand Down

0 comments on commit 8a6afb9

Please sign in to comment.