Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: virt-dma: Add missing locking around list operations

All list operations are protected by &vc->lock. As vchan_vdesc_fini()
is called unlocked add the missing locking around the list operations.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Tested-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20191216105328.15198-6-s.hauer@pengutronix.de
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Sascha Hauer and committed by
Vinod Koul
9f91e6bf f8821011

+7 -2
+7 -2
drivers/dma/virt-dma.h
··· 113 113 { 114 114 struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan); 115 115 116 - if (dmaengine_desc_test_reuse(&vd->tx)) 116 + if (dmaengine_desc_test_reuse(&vd->tx)) { 117 + unsigned long flags; 118 + 119 + spin_lock_irqsave(&vc->lock, flags); 117 120 list_add(&vd->node, &vc->desc_allocated); 118 - else 121 + spin_unlock_irqrestore(&vc->lock, flags); 122 + } else { 119 123 vc->desc_free(vd); 124 + } 120 125 } 121 126 122 127 /**