Skip to contentSkip to conversation

dmaengine: at_xdmac: check for non-empty xfers_list before invoking callback

PATCH Applied Raag Jadav 3 participants 3 messages Jun 29, 2019 – Jul 7, 2019

Subsystems (2)
lore
Share & tools
lore

Raag Jadav

author
#0 lore raw

PATCH 1/1 dmaengine: at_xdmac: check for non-empty xfers_list before invoking callback

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.

---
 drivers/dma/at_xdmac.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/dma/at_xdmac.c +7 -4
index 627ef3e..b58ac72 100644
@@ -1568,11 +1568,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)
Signature · 1 line
2.7.4
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Raag Jadav

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.

Thanks

Quoted 31 lines
---
 drivers/dma/at_xdmac.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/dma/at_xdmac.c +7 -4
index 627ef3e..b58ac72 100644
@@ -1568,11 +1568,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)
Signature · 1 line
2.7.4
maintainer Applied
#2 lore raw
In reply to Raag Jadav
Quoted 3 lines · Raag Jadav

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.

Applied, thanks

Signature · 1 line
~Vinod