From: Vinod Koul <vinod.koul@intel.com>
To: linux-sh@vger.kernel.org
Subject: Re: [PATCH] dmaengine: usb-dmac: fix endless loop in usb_dmac_chan_terminate_all()
Date: Mon, 16 Nov 2015 03:58:50 +0000 [thread overview]
Message-ID: <20151116034649.GZ25173@localhost> (raw)
In-Reply-To: <1447303060-7880-1-git-send-email-yoshihiro.shimoda.uh@renesas.com>
On Thu, Nov 12, 2015 at 01:37:40PM +0900, Yoshihiro Shimoda wrote:
> 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().
Sorry this is not clear to my why this owuld have endless loop, can you
explain more
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@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 ebd8a5f..16fb330 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);
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe dmaengine" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
~Vinod
next prev parent reply other threads:[~2015-11-16 3:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-12 4:37 [PATCH] dmaengine: usb-dmac: fix endless loop in usb_dmac_chan_terminate_all() Yoshihiro Shimoda
2015-11-16 3:58 ` Vinod Koul [this message]
2015-11-16 7:13 ` Yoshihiro Shimoda
2015-12-05 8:20 ` Vinod Koul
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=20151116034649.GZ25173@localhost \
--to=vinod.koul@intel.com \
--cc=linux-sh@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).