Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8a6afb9a authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Grant Likely
Browse files

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: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent c56eb8fb
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -509,9 +509,11 @@ static int sh_msiof_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
	bytes_done = 0;
	bytes_done = 0;


	while (bytes_done < t->len) {
	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,
		n = sh_msiof_spi_txrx_once(p, tx_fifo, rx_fifo,
					   t->tx_buf + bytes_done,
					   tx_buf,
					   t->rx_buf + bytes_done,
					   rx_buf,
					   words, bits);
					   words, bits);
		if (n < 0)
		if (n < 0)
			break;
			break;