MLK-14976: dma: virt-dma: free description after callback
authorRobin Gong <yibin.gong@nxp.com>
Wed, 24 May 2017 08:28:43 +0000 (16:28 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:22:24 +0000 (15:22 -0500)
Some drivers may access dma_async_tx_descriptor in callback such as
tty/serial/fsl_lpuart.c, but the description has already been freed
before callback, memory corrupt here. Move the free description
behind of callback.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
drivers/dma/virt-dma.c

index e47fc9b..c940cec 100644 (file)
@@ -108,12 +108,13 @@ static void vchan_complete(unsigned long arg)
                dmaengine_desc_get_callback(&vd->tx, &cb);
 
                list_del(&vd->node);
+
+               dmaengine_desc_callback_invoke(&cb, NULL);
+
                if (dmaengine_desc_test_reuse(&vd->tx))
                        list_add(&vd->node, &vc->desc_allocated);
                else
                        vc->desc_free(vd);
-
-               dmaengine_desc_callback_invoke(&cb, NULL);
        }
 }