Skip to content

Commit

Permalink
spi/mpc8xxx: fix buffer overrun on large transfers
Browse files Browse the repository at this point in the history
It fixes an issue when sending-only or receiving-only more than
PAGE_SIZE bytes.

Signed-off-by: christophe leroy <[email protected]>
Acked-by: Joakim Tjernlund <[email protected]>
Signed-off-by: Grant Likely <[email protected]>
  • Loading branch information
chleroy authored and glikely committed Sep 16, 2010
1 parent 9c03f16 commit 37880c9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/spi/spi_mpc8xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,17 @@ static void mpc8xxx_spi_cpm_bufs_start(struct mpc8xxx_spi *mspi)

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);
Expand Down

0 comments on commit 37880c9

Please sign in to comment.