aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorJoakim Tjernlund <Joakim.Tjernlund@transmode.se>2010-05-22 04:18:02 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-05-22 04:18:02 -0400
commitf9218c2a60facc6ff9a793a9d9ab956194d70012 (patch)
tree03876aab569a848ee44b741fd389856738470148 /drivers/spi
parente40152ee1e1c7a63f4777791863215e3faa37a86 (diff)
spi/spi_mpc8xxx: fix potential memory corruption.
tx_dma/rx_dma are already set to a dummy buffer when no tx/rx buffer and t->tx_dma/t->rx_dma does not contain a dma address, but NULL. This may lead to corruption of kernel memory. Fix this by leaving tx_dma/rx_dma alone. Do not INIT_TX_RX while controller is enabled, this is bad according to the MPC8321 manual. Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> Acked-by: Anton Vorontsov <cbouatmailru@gmail.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi_mpc8xxx.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c
index 14d052316502..0dfc482bbff5 100644
--- a/drivers/spi/spi_mpc8xxx.c
+++ b/drivers/spi/spi_mpc8xxx.c
@@ -241,7 +241,6 @@ static void mpc8xxx_spi_change_mode(struct spi_device *spi)
241 241
242 /* Turn off SPI unit prior changing mode */ 242 /* Turn off SPI unit prior changing mode */
243 mpc8xxx_spi_write_reg(mode, cs->hw_mode & ~SPMODE_ENABLE); 243 mpc8xxx_spi_write_reg(mode, cs->hw_mode & ~SPMODE_ENABLE);
244 mpc8xxx_spi_write_reg(mode, cs->hw_mode);
245 244
246 /* When in CPM mode, we need to reinit tx and rx. */ 245 /* When in CPM mode, we need to reinit tx and rx. */
247 if (mspi->flags & SPI_CPM_MODE) { 246 if (mspi->flags & SPI_CPM_MODE) {
@@ -258,7 +257,7 @@ static void mpc8xxx_spi_change_mode(struct spi_device *spi)
258 } 257 }
259 } 258 }
260 } 259 }
261 260 mpc8xxx_spi_write_reg(mode, cs->hw_mode);
262 local_irq_restore(flags); 261 local_irq_restore(flags);
263} 262}
264 263
@@ -438,7 +437,7 @@ static int mpc8xxx_spi_cpm_bufs(struct mpc8xxx_spi *mspi,
438 dev_err(dev, "unable to map tx dma\n"); 437 dev_err(dev, "unable to map tx dma\n");
439 return -ENOMEM; 438 return -ENOMEM;
440 } 439 }
441 } else { 440 } else if (t->tx_buf) {
442 mspi->tx_dma = t->tx_dma; 441 mspi->tx_dma = t->tx_dma;
443 } 442 }
444 443
@@ -449,7 +448,7 @@ static int mpc8xxx_spi_cpm_bufs(struct mpc8xxx_spi *mspi,
449 dev_err(dev, "unable to map rx dma\n"); 448 dev_err(dev, "unable to map rx dma\n");
450 goto err_rx_dma; 449 goto err_rx_dma;
451 } 450 }
452 } else { 451 } else if (t->rx_buf) {
453 mspi->rx_dma = t->rx_dma; 452 mspi->rx_dma = t->rx_dma;
454 } 453 }
455 454