dmaengine Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] dmaengine: at_xdmac: check for non-empty xfers_list before invoking callback
@ 2019-06-29  8:20 Raag Jadav
  2019-07-01  8:00 ` Ludovic Desroches
  2019-07-07 17:17 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Raag Jadav @ 2019-06-29  8:20 UTC (permalink / raw)
  To: dmaengine, Vinod Koul
  Cc: Ludovic Desroches, Dan Williams, linux-arm-kernel, linux-kernel,
	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.

Signed-off-by: Raag Jadav <raagjadav@gmail.com>
---
 drivers/dma/at_xdmac.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index 627ef3e..b58ac72 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -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)
-- 
2.7.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: at_xdmac: check for non-empty xfers_list before invoking callback
  2019-06-29  8:20 [PATCH] dmaengine: at_xdmac: check for non-empty xfers_list before invoking callback Raag Jadav
@ 2019-07-01  8:00 ` Ludovic Desroches
  2019-07-07 17:17 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Ludovic Desroches @ 2019-07-01  8:00 UTC (permalink / raw)
  To: Raag Jadav
  Cc: dmaengine, Vinod Koul, Dan Williams, linux-arm-kernel, linux-kernel

On Sat, Jun 29, 2019 at 01:50:48PM +0530, Raag Jadav wrote:
> 
> 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>

Thanks

> ---
>  drivers/dma/at_xdmac.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
> index 627ef3e..b58ac72 100644
> --- a/drivers/dma/at_xdmac.c
> +++ b/drivers/dma/at_xdmac.c
> @@ -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)
> -- 
> 2.7.4
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: at_xdmac: check for non-empty xfers_list before invoking callback
  2019-06-29  8:20 [PATCH] dmaengine: at_xdmac: check for non-empty xfers_list before invoking callback Raag Jadav
  2019-07-01  8:00 ` Ludovic Desroches
@ 2019-07-07 17:17 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2019-07-07 17:17 UTC (permalink / raw)
  To: Raag Jadav
  Cc: dmaengine, Ludovic Desroches, Dan Williams, linux-arm-kernel,
	linux-kernel

On 29-06-19, 13:50, Raag Jadav wrote:
> 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

-- 
~Vinod

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-29  8:20 [PATCH] dmaengine: at_xdmac: check for non-empty xfers_list before invoking callback Raag Jadav
2019-07-01  8:00 ` Ludovic Desroches
2019-07-07 17:17 ` Vinod Koul

dmaengine Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dmaengine/0 dmaengine/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dmaengine dmaengine/ https://lore.kernel.org/dmaengine \
		dmaengine@vger.kernel.org
	public-inbox-index dmaengine

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.dmaengine


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git