From: Peter Ujfalusi Date: Fri, 20 Dec 2019 13:11:00 +0000 (+0200) Subject: dmaengine: virt-dma: Fix access after free in vchan_complete() X-Git-Tag: v5.4.9~69 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fdfd8f9ef2d3a35764e8fabc035bd0bbb382e318;p=platform%2Fkernel%2Flinux-rpi.git dmaengine: virt-dma: Fix access after free in vchan_complete() commit 24461d9792c2c706092805ff1b067628933441bd upstream. 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: 09d5b702b0f97 ("dmaengine: virt-dma: store result on dma descriptor") Signed-off-by: Peter Ujfalusi Reviewed-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20191220131100.21804-1-peter.ujfalusi@ti.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/dma/virt-dma.c b/drivers/dma/virt-dma.c index ec4adf4..256fc66 100644 --- a/drivers/dma/virt-dma.c +++ b/drivers/dma/virt-dma.c @@ -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); } }