spi: check tx_buf and rx_buf in spi_unmap_msg
[firefly-linux-kernel-4.4.55.git] / drivers / spi / spi.c
index d5d7d2235163f9ef8c6430d99544ec7f2c791c6b..50910d85df5af28d6f281485cc79d4b3e15bc7e5 100644 (file)
@@ -583,6 +583,15 @@ static int spi_unmap_msg(struct spi_master *master, struct spi_message *msg)
        rx_dev = master->dma_rx->device->dev;
 
        list_for_each_entry(xfer, &msg->transfers, transfer_list) {
+               /*
+                * Restore the original value of tx_buf or rx_buf if they are
+                * NULL.
+                */
+               if (xfer->tx_buf == master->dummy_tx)
+                       xfer->tx_buf = NULL;
+               if (xfer->rx_buf == master->dummy_rx)
+                       xfer->rx_buf = NULL;
+
                if (!master->can_dma(master, msg->spi, xfer))
                        continue;