Skip to contentSkip to conversation

spi_mpc8xxx: fix buffer overrun when sending only/receiving only more than PAGE_SIZE bytes

PATCH Applied christophe leroy 3 participants 3 messages Sep 16, 2010 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi_mpc8xxx: fix buffer overrun when sending only/receiving only more than PAGE_SIZE bytes

This patch applies to 2.6.34.7 and 2.6.35.4
It fixes an issue when sending only or receiving only more than PAGE_SIZE bytes

drivers/spi/spi_mpc8xxx.c +8 -2
diff -urN c/drivers/spi/spi_mpc8xxx.c d/drivers/spi/spi_mpc8xxx.c
@@ -393,11 +393,17 @@
 
 	xfer_ofs = mspi->xfer_in_progress->len - mspi->count;
 
-	out_be32(&rx_bd->cbd_bufaddr, mspi->rx_dma + xfer_ofs);
+	if (mspi->rx_dma == mspi->dma_dummy_rx)
+		out_be32(&rx_bd->cbd_bufaddr, mspi->rx_dma);
+	else
+		out_be32(&rx_bd->cbd_bufaddr, mspi->rx_dma + xfer_ofs);
 	out_be16(&rx_bd->cbd_datlen, 0);
 	out_be16(&rx_bd->cbd_sc, BD_SC_EMPTY | BD_SC_INTRPT | BD_SC_WRAP);
 
-	out_be32(&tx_bd->cbd_bufaddr, mspi->tx_dma + xfer_ofs);
+	if (mspi->tx_dma == mspi->dma_dummy_tx)
+		out_be32(&tx_bd->cbd_bufaddr, mspi->tx_dma);
+	else
+		out_be32(&tx_bd->cbd_bufaddr, mspi->tx_dma + xfer_ofs);
 	out_be16(&tx_bd->cbd_datlen, xfer_len);
 	out_be16(&tx_bd->cbd_sc, BD_SC_READY | BD_SC_INTRPT | BD_SC_WRAP |
 				 BD_SC_LAST);
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines

From: christophe leroy <[email protected]>
To: David Brownell <[email protected]>, Grant Likely <[email protected]>, [email protected], linux- [email protected], [email protected]
Date: 2010/09/16 09:07
Subject: [PATCH] spi_mpc8xxx: fix buffer overrun when sending only/receiving only more than PAGE_SIZE bytes
Sent by: linuxppc-dev-bounces+joakim.tjernlund=transmode.se@lists.ozlabs.org

Quoted 4 lines

This patch applies to 2.6.34.7 and 2.6.35.4
It fixes an issue when sending only or receiving only more than PAGE_SIZE bytes

Applied
#2 lore raw
In reply to christophe leroy
Quoted 4 lines · christophe leroy

This patch applies to 2.6.34.7 and 2.6.35.4
It fixes an issue when sending only or receiving only more than PAGE_SIZE bytes

applied to merge-spi branch, thanks.

g.

Quoted 24 lines

diff -urN c/drivers/spi/spi_mpc8xxx.c d/drivers/spi/spi_mpc8xxx.c

drivers/spi/spi_mpc8xxx.c +8 -2
@@ -393,11 +393,17 @@
 
 	xfer_ofs = mspi->xfer_in_progress->len - mspi->count;
 
-	out_be32(&rx_bd->cbd_bufaddr, mspi->rx_dma + xfer_ofs);
+	if (mspi->rx_dma == mspi->dma_dummy_rx)
+		out_be32(&rx_bd->cbd_bufaddr, mspi->rx_dma);
+	else
+		out_be32(&rx_bd->cbd_bufaddr, mspi->rx_dma + xfer_ofs);
 	out_be16(&rx_bd->cbd_datlen, 0);
 	out_be16(&rx_bd->cbd_sc, BD_SC_EMPTY | BD_SC_INTRPT | BD_SC_WRAP);
 
-	out_be32(&tx_bd->cbd_bufaddr, mspi->tx_dma + xfer_ofs);
+	if (mspi->tx_dma == mspi->dma_dummy_tx)
+		out_be32(&tx_bd->cbd_bufaddr, mspi->tx_dma);
+	else
+		out_be32(&tx_bd->cbd_bufaddr, mspi->tx_dma + xfer_ofs);
 	out_be16(&tx_bd->cbd_datlen, xfer_len);
 	out_be16(&tx_bd->cbd_sc, BD_SC_READY | BD_SC_INTRPT | BD_SC_WRAP |
 				 BD_SC_LAST);