All of lore.kernel.org
 help / color / mirror / Atom feed
From: biju.das@bp.renesas.com (Biju Das)
To: cip-dev@lists.cip-project.org
Subject: [cip-dev] [RFC PATCH 6/7] dmaengine: usb-dmac: fix endless loop in usb_dmac_chan_terminate_all()
Date: Thu, 24 May 2018 17:05:09 +0100	[thread overview]
Message-ID: <1527177910-65275-7-git-send-email-biju.das@bp.renesas.com> (raw)
In-Reply-To: <1527177910-65275-1-git-send-email-biju.das@bp.renesas.com>

From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

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>
(cherry picked from commit d9f5efade2cfd729138a7cafb46d01044da40f5e)
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/dma/sh/usb-dmac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c
index 56410ea..6682b3e 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,
 static int usb_dmac_chan_terminate_all(struct dma_chan *chan)
 {
 	struct usb_dmac_chan *uchan = to_usb_dmac_chan(chan);
-	struct usb_dmac_desc *desc;
+	struct usb_dmac_desc *desc, *_desc;
 	unsigned long flags;
 	LIST_HEAD(head);
 	LIST_HEAD(list);
@@ -459,7 +459,7 @@ static int usb_dmac_chan_terminate_all(struct dma_chan *chan)
 	if (uchan->desc)
 		uchan->desc = NULL;
 	list_splice_init(&uchan->desc_got, &list);
-	list_for_each_entry(desc, &list, node)
+	list_for_each_entry_safe(desc, _desc, &list, node)
 		list_move_tail(&desc->node, &uchan->desc_freed);
 	spin_unlock_irqrestore(&uchan->vc.lock, flags);
 	vchan_dma_desc_free_list(&uchan->vc, &head);
-- 
2.7.4

  parent reply	other threads:[~2018-05-24 16:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-24 16:05 [cip-dev] [RFC PATCH 0/7] 'SKB reserve' quirk setup to u_ether Biju Das
2018-05-24 16:05 ` [cip-dev] [RFC PATCH 1/7] usb: gadget: add a new quirk to avoid skb_reserve in u_ether.c Biju Das
2018-05-24 16:05 ` [cip-dev] [RFC PATCH 2/7] usb: gadget: u_ether: add a flag to avoid skb_reserve() calling Biju Das
2018-05-24 16:05 ` [cip-dev] [RFC PATCH 3/7] usb: gadget: f_ncm: add support for no_skb_reserve Biju Das
2018-05-24 16:05 ` [cip-dev] [RFC PATCH 4/7] usb: renesas_usbhs: set quirk_avoids_skb_reserve if USB-DMAC is used Biju Das
2018-05-24 16:05 ` [cip-dev] [RFC PATCH 5/7] usb: gadget: f_ncm/u_ether: Move 'SKB reserve' quirk setup to u_ether Biju Das
2018-05-24 16:05 ` Biju Das [this message]
2018-05-24 16:05 ` [cip-dev] [RFC PATCH 7/7] ARM: shmobile: defconfig: Enable missing support based on DTSes Biju Das
2018-05-30 18:04   ` Ben Hutchings
2018-05-30 18:16     ` Biju Das
2018-05-30 18:22       ` Ben Hutchings
2018-05-30 18:26         ` Biju Das
2018-05-30 17:44 ` [cip-dev] [RFC PATCH 0/7] 'SKB reserve' quirk setup to u_ether Ben Hutchings
2018-06-26  9:13   ` Biju Das
2018-07-08 20:02     ` Ben Hutchings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1527177910-65275-7-git-send-email-biju.das@bp.renesas.com \
    --to=biju.das@bp.renesas.com \
    --cc=cip-dev@lists.cip-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.