[PATCH 03/14] dmaengine: dma350: Check vchan_next_desc() return value

Robin Murphy robin.murphy at arm.com
Fri Aug 29 03:02:06 PDT 2025


On 2025-08-23 4:39 pm, Jisheng Zhang wrote:
> vchan_next_desc() may return NULL, check its return value.

IIRC it's important that dch->desc gets set to NULL in that case, 
otherwise things can go wonky after a completion interrupt - i.e. the 
current code *is* using the return value both ways, just the sneaky 
thing is that it does actually depend on "vd" being the first member of 
d350_desc to do it concisely, sorry I didn't document that.

Thanks,
Robin.
> Signed-off-by: Jisheng Zhang <jszhang at kernel.org>
> ---
>   drivers/dma/arm-dma350.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/arm-dma350.c b/drivers/dma/arm-dma350.c
> index 24cbadc5f076..96350d15ed85 100644
> --- a/drivers/dma/arm-dma350.c
> +++ b/drivers/dma/arm-dma350.c
> @@ -399,11 +399,14 @@ static enum dma_status d350_tx_status(struct dma_chan *chan, dma_cookie_t cookie
>   static void d350_start_next(struct d350_chan *dch)
>   {
>   	u32 hdr, *reg;
> +	struct virt_dma_desc *vd;
>   
> -	dch->desc = to_d350_desc(vchan_next_desc(&dch->vc));
> -	if (!dch->desc)
> +	vd = vchan_next_desc(&dch->vc);
> +	if (!vd)
>   		return;
>   
> +	dch->desc = to_d350_desc(vd);
> +
>   	list_del(&dch->desc->vd.node);
>   	dch->status = DMA_IN_PROGRESS;
>   	dch->cookie = dch->desc->vd.tx.cookie;




More information about the linux-arm-kernel mailing list