qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: P J P <ppandit@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: Prasad J Pandit <pjp@fedoraproject.org>,
	Li Qiang <liq3ea@gmail.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Yi Ren <yunye.ry@alibaba-inc.com>,
	Yongkang Jia <j_kangel@163.com>, Gaoning Pan <pgn@zju.edu.cn>
Subject: [PATCH v2 2/2] hw: usb: hcd-ohci: check for processed TD before retire
Date: Tue, 15 Sep 2020 23:52:59 +0530	[thread overview]
Message-ID: <20200915182259.68522-3-ppandit@redhat.com> (raw)
In-Reply-To: <20200915182259.68522-1-ppandit@redhat.com>

From: Prasad J Pandit <pjp@fedoraproject.org>

While servicing OHCI transfer descriptors(TD), ohci_service_iso_td
retires a TD if it has passed its time frame. It does not check if
the TD was already processed once and holds an error code in TD_CC.
It may happen if the TD list has a loop. Add check to avoid an
infinite loop condition.

Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 hw/usb/hcd-ohci.c | 4 ++++
 1 file changed, 4 insertions(+)

Update v2: one patch for loop issue
  -> https://lists.nongnu.org/archive/html/qemu-devel/2020-09/msg05145.html

diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 9dc59101f9..8b912e95d3 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -691,6 +691,10 @@ static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed,
            the next ISO TD of the same ED */
         trace_usb_ohci_iso_td_relative_frame_number_big(relative_frame_number,
                                                         frame_count);
+        if (OHCI_CC_DATAOVERRUN == OHCI_BM(iso_td.flags, TD_CC)) {
+            /* avoid infinite loop */
+            return 1;
+        }
         OHCI_SET_BM(iso_td.flags, TD_CC, OHCI_CC_DATAOVERRUN);
         ed->head &= ~OHCI_DPTR_MASK;
         ed->head |= (iso_td.next & OHCI_DPTR_MASK);
-- 
2.26.2



  parent reply	other threads:[~2020-09-15 18:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15 18:22 [PATCH v2 0/2] hw: usb: hcd-ohci: fix oob access and loop issues P J P
2020-09-15 18:22 ` [PATCH v2 1/2] hw: usb: hcd-ohci: check len and frame_number variables P J P
2020-09-15 18:22 ` P J P [this message]
2020-09-16 14:51   ` [PATCH v2 2/2] hw: usb: hcd-ohci: check for processed TD before retire Li Qiang
2020-09-21  7:53 ` [PATCH v2 0/2] hw: usb: hcd-ohci: fix oob access and loop issues Gerd Hoffmann

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=20200915182259.68522-3-ppandit@redhat.com \
    --to=ppandit@redhat.com \
    --cc=j_kangel@163.com \
    --cc=kraxel@redhat.com \
    --cc=liq3ea@gmail.com \
    --cc=pgn@zju.edu.cn \
    --cc=pjp@fedoraproject.org \
    --cc=qemu-devel@nongnu.org \
    --cc=yunye.ry@alibaba-inc.com \
    /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).