Skip to content

Commit

Permalink
dmaengine: virt-dma: Fix access after free in vchan_complete()
Browse files Browse the repository at this point in the history
vchan_vdesc_fini() is freeing up 'vd' so the access to vd->tx_result is
via already freed up memory.

Move the vchan_vdesc_fini() after invoking the callback to avoid this.

Fixes: 09d5b70 ("dmaengine: virt-dma: store result on dma descriptor")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20191220131100.21804-1-peter.ujfalusi@ti.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
  • Loading branch information
Peter Ujfalusi authored and vinodkoul committed Dec 23, 2019
1 parent 2f42e05 commit 24461d9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/dma/virt-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ static void vchan_complete(unsigned long arg)
dmaengine_desc_get_callback(&vd->tx, &cb);

list_del(&vd->node);
vchan_vdesc_fini(vd);

dmaengine_desc_callback_invoke(&cb, &vd->tx_result);
vchan_vdesc_fini(vd);
}
}

Expand Down

0 comments on commit 24461d9

Please sign in to comment.