dmaengine: at_xdmac: check for non-empty xfers_list before invoking callback
authorRaag Jadav <raagjadav@gmail.com>
Sat, 29 Jun 2019 08:20:48 +0000 (13:50 +0530)
committerVinod Koul <vkoul@kernel.org>
Sun, 7 Jul 2019 17:16:43 +0000 (22:46 +0530)
tx descriptor retrieved from an empty xfers_list may not have valid
pointers to the callback functions.
Avoid calling dmaengine_desc_get_callback_invoke if xfers_list is empty.

Signed-off-by: Raag Jadav <raagjadav@gmail.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/at_xdmac.c

index e4ae2ee46d3f9d18477b7bbdb1c8d4f43af66e75..84b3c6ac31ccf0aab04334dbc4ffba9176511e6b 100644 (file)
@@ -1579,11 +1579,14 @@ static void at_xdmac_handle_cyclic(struct at_xdmac_chan *atchan)
        struct at_xdmac_desc            *desc;
        struct dma_async_tx_descriptor  *txd;
 
-       desc = list_first_entry(&atchan->xfers_list, struct at_xdmac_desc, xfer_node);
-       txd = &desc->tx_dma_desc;
+       if (!list_empty(&atchan->xfers_list)) {
+               desc = list_first_entry(&atchan->xfers_list,
+                                       struct at_xdmac_desc, xfer_node);
+               txd = &desc->tx_dma_desc;
 
-       if (txd->flags & DMA_PREP_INTERRUPT)
-               dmaengine_desc_get_callback_invoke(txd, NULL);
+               if (txd->flags & DMA_PREP_INTERRUPT)
+                       dmaengine_desc_get_callback_invoke(txd, NULL);
+       }
 }
 
 static void at_xdmac_handle_error(struct at_xdmac_chan *atchan)