qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH 6/6] xhci: move sanity checks
Date: Thu,  5 Nov 2020 14:41:12 +0100	[thread overview]
Message-ID: <20201105134112.25119-7-kraxel@redhat.com> (raw)
In-Reply-To: <20201105134112.25119-1-kraxel@redhat.com>

The v variable goes negative for reg < 0x20.  Reorder the code
to first sanity check then calculate v and assign intr to make
sanity checkers happy.

Buglink: https://bugs.launchpad.net/qemu/+bug/1902112
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/hcd-xhci.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index d00bb0141dac..6dfb17cbe915 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3010,14 +3010,17 @@ static void xhci_runtime_write(void *ptr, hwaddr reg,
                                uint64_t val, unsigned size)
 {
     XHCIState *xhci = ptr;
-    int v = (reg - 0x20) / 0x20;
-    XHCIInterrupter *intr = &xhci->intr[v];
+    XHCIInterrupter *intr;
+    int v;
+
     trace_usb_xhci_runtime_write(reg, val);
 
     if (reg < 0x20) {
         trace_usb_xhci_unimplemented("runtime write", reg);
         return;
     }
+    v = (reg - 0x20) / 0x20;
+    intr = &xhci->intr[v];
 
     switch (reg & 0x1f) {
     case 0x00: /* IMAN */
-- 
2.27.0



  parent reply	other threads:[~2020-11-05 13:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05 13:41 [PATCH 0/6] usb: fix some guest-triggerable asserts Gerd Hoffmann
2020-11-05 13:41 ` [PATCH 1/6] usb-storage: switch trace events Gerd Hoffmann
2020-11-05 14:26   ` Philippe Mathieu-Daudé
2020-11-05 13:41 ` [PATCH 2/6] usb-storage: add commandlog property Gerd Hoffmann
2020-11-05 14:27   ` Philippe Mathieu-Daudé
2020-11-05 13:41 ` [PATCH 3/6] usb-storage: use bool for removable property Gerd Hoffmann
2020-11-05 14:27   ` Philippe Mathieu-Daudé
2020-11-05 13:41 ` [PATCH 4/6] usb-storage: fill csw on cancel Gerd Hoffmann
2020-11-05 13:41 ` [PATCH 5/6] xhci: fix guest triggerable assert Gerd Hoffmann
2020-11-05 14:28   ` Philippe Mathieu-Daudé
2020-11-05 13:41 ` Gerd Hoffmann [this message]
2020-11-05 14:30   ` [PATCH 6/6] xhci: move sanity checks Philippe Mathieu-Daudé

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=20201105134112.25119-7-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.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).