Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1673522
| From | Amelie Delaunay <amelie.delaunay@st.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 8/8] spi: stm32: fix potential dereference null return value |
| Date | 2017-06-23 15:00 +0200 |
| Message-ID | <tVwlP-2ge-3@gated-at.bofh.it> (permalink) |
| References | <tVwlP-2ge-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
This patch fixes the usage of rx_dma_desc and tx_dma_desc pointers
returned by dmaengine_prep_slave_sg, which can be null.
Detected by CoverityScan, CID#1446587 ("Dereference null return value")
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
---
drivers/spi/spi-stm32.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 63af9d9..076a720 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -775,9 +775,6 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi,
xfer->rx_sg.nents,
rx_dma_conf.direction,
DMA_PREP_INTERRUPT);
-
- rx_dma_desc->callback = stm32_spi_dma_cb;
- rx_dma_desc->callback_param = spi;
}
tx_dma_desc = NULL;
@@ -790,11 +787,6 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi,
xfer->tx_sg.nents,
tx_dma_conf.direction,
DMA_PREP_INTERRUPT);
-
- if (spi->cur_comm == SPI_SIMPLEX_TX) {
- tx_dma_desc->callback = stm32_spi_dma_cb;
- tx_dma_desc->callback_param = spi;
- }
}
if ((spi->tx_buf && !tx_dma_desc) ||
@@ -802,6 +794,9 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi,
goto dma_desc_error;
if (rx_dma_desc) {
+ rx_dma_desc->callback = stm32_spi_dma_cb;
+ rx_dma_desc->callback_param = spi;
+
if (dma_submit_error(dmaengine_submit(rx_dma_desc))) {
dev_err(spi->dev, "Rx DMA submit failed\n");
goto dma_desc_error;
@@ -811,6 +806,11 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi,
}
if (tx_dma_desc) {
+ if (spi->cur_comm == SPI_SIMPLEX_TX) {
+ tx_dma_desc->callback = stm32_spi_dma_cb;
+ tx_dma_desc->callback_param = spi;
+ }
+
if (dma_submit_error(dmaengine_submit(tx_dma_desc))) {
dev_err(spi->dev, "Tx DMA submit failed\n");
goto dma_submit_error;
--
1.9.1
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH 8/8] spi: stm32: fix potential dereference null return value Amelie Delaunay <amelie.delaunay@st.com> - 2017-06-23 15:00 +0200 Applied "spi: stm32: fix potential dereference null return value" to the spi tree Mark Brown <broonie@kernel.org> - 2017-06-28 21:30 +0200
csiph-web