Skip to content

Commit dbd45f0

Browse files
Niklas Söderlundh-yokoya
authored andcommitted
dmaengine: rcar-dmac: wait for ISR to finish before freeing resources
This fixes a race condition where the channel resources could be freed before the ISR had finished running resulting in a NULL pointer reference from the ISR. [ 167.148934] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [ 167.157051] pgd = ffff80003c641000 [ 167.160449] [00000000] *pgd=000000007c507003, *pud=000000007c4ff003, *pmd=0000000000000000 [ 167.168719] Internal error: Oops: 96000046 [#1] PREEMPT SMP [ 167.174289] Modules linked in: [ 167.177348] CPU: 3 PID: 10547 Comm: dma_ioctl Not tainted 4.11.0-rc1-00001-g8d92afddc2f6633a xen-troops#73 [ 167.186131] Hardware name: Renesas Salvator-X board based on r8a7795 (DT) [ 167.192917] task: ffff80003a411a00 task.stack: ffff80003bcd4000 [ 167.198850] PC is at rcar_dmac_chan_prep_sg+0xe0/0x400 [ 167.203985] LR is at rcar_dmac_chan_prep_sg+0x48/0x400 Based of previous work by: Hiroyuki Yokoyama <[email protected]>. Signed-off-by: Niklas Söderlund <[email protected]> Signed-off-by: Vinod Koul <[email protected]> (cherry picked from commit a1ed64e) Signed-off-by: Hiroyuki Yokoyama <[email protected]>
1 parent 9a0958a commit dbd45f0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/dma/sh/rcar-dmac.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,11 @@ static void rcar_dmac_free_chan_resources(struct dma_chan *chan)
998998
rcar_dmac_chan_halt(rchan);
999999
spin_unlock_irq(&rchan->lock);
10001000

1001-
/* Now no new interrupts will occur */
1001+
/*
1002+
* Now no new interrupts will occur, but one might already be
1003+
* running. Wait for it to finish before freeing resources.
1004+
*/
1005+
synchronize_irq(rchan->irq);
10021006

10031007
if (rchan->mid_rid >= 0) {
10041008
/* The caller is holding dma_list_mutex */

0 commit comments

Comments
 (0)