Skip to content

Commit

Permalink
dmaengine: imx-dma: fix callback path in tasklet
Browse files Browse the repository at this point in the history
We need to free the ld_active list head before jumping into the callback
routine. Otherwise the callback could run into issue_pending and change
our ld_active list head we just going to free. This will run the channel
list into an currupted and undefined state.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
  • Loading branch information
Michael Grzeschik authored and Vinod Koul committed Oct 4, 2013
1 parent 5a276fa commit fcaaba6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/dma/imx-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,13 +627,11 @@ static void imxdma_tasklet(unsigned long data)

if (list_empty(&imxdmac->ld_active)) {
/* Someone might have called terminate all */
goto out;
spin_unlock_irqrestore(&imxdma->lock, flags);
return;
}
desc = list_first_entry(&imxdmac->ld_active, struct imxdma_desc, node);

if (desc->desc.callback)
desc->desc.callback(desc->desc.callback_param);

/* If we are dealing with a cyclic descriptor, keep it on ld_active
* and dont mark the descriptor as complete.
* Only in non-cyclic cases it would be marked as complete
Expand Down Expand Up @@ -661,6 +659,10 @@ static void imxdma_tasklet(unsigned long data)
}
out:
spin_unlock_irqrestore(&imxdma->lock, flags);

if (desc->desc.callback)
desc->desc.callback(desc->desc.callback_param);

}

static int imxdma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
Expand Down

0 comments on commit fcaaba6

Please sign in to comment.