aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>2015-11-11 23:37:40 -0500
committerVinod Koul <vinod.koul@intel.com>2015-12-05 03:07:51 -0500
commitd9f5efade2cfd729138a7cafb46d01044da40f5e (patch)
tree2fae86741445e847c585f22eaeddad165e9dcec6
parent8005c49d9aea74d382f474ce11afbbc7d7130bec (diff)
dmaengine: usb-dmac: fix endless loop in usb_dmac_chan_terminate_all()
This patch fixes an issue that list_for_each_entry() in usb_dmac_chan_terminate_all() is possible to cause endless loop because this will move own desc to the desc_freed. So, this driver should use list_for_each_entry_safe() instead of list_for_each_entry(). Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r--drivers/dma/sh/usb-dmac.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c
index ebd8a5f398b0..16fb33006a17 100644
--- a/drivers/dma/sh/usb-dmac.c
+++ b/drivers/dma/sh/usb-dmac.c
@@ -448,7 +448,7 @@ usb_dmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
448static int usb_dmac_chan_terminate_all(struct dma_chan *chan) 448static int usb_dmac_chan_terminate_all(struct dma_chan *chan)
449{ 449{
450 struct usb_dmac_chan *uchan = to_usb_dmac_chan(chan); 450 struct usb_dmac_chan *uchan = to_usb_dmac_chan(chan);
451 struct usb_dmac_desc *desc; 451 struct usb_dmac_desc *desc, *_desc;
452 unsigned long flags; 452 unsigned long flags;
453 LIST_HEAD(head); 453 LIST_HEAD(head);
454 LIST_HEAD(list); 454 LIST_HEAD(list);
@@ -459,7 +459,7 @@ static int usb_dmac_chan_terminate_all(struct dma_chan *chan)
459 if (uchan->desc) 459 if (uchan->desc)
460 uchan->desc = NULL; 460 uchan->desc = NULL;
461 list_splice_init(&uchan->desc_got, &list); 461 list_splice_init(&uchan->desc_got, &list);
462 list_for_each_entry(desc, &list, node) 462 list_for_each_entry_safe(desc, _desc, &list, node)
463 list_move_tail(&desc->node, &uchan->desc_freed); 463 list_move_tail(&desc->node, &uchan->desc_freed);
464 spin_unlock_irqrestore(&uchan->vc.lock, flags); 464 spin_unlock_irqrestore(&uchan->vc.lock, flags);
465 vchan_dma_desc_free_list(&uchan->vc, &head); 465 vchan_dma_desc_free_list(&uchan->vc, &head);