[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/6] xhci: move sanity checks
From: |
Gerd Hoffmann |
Subject: |
[PATCH 6/6] xhci: move sanity checks |
Date: |
Thu, 5 Nov 2020 14:41:12 +0100 |
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
- [PATCH 0/6] usb: fix some guest-triggerable asserts, Gerd Hoffmann, 2020/11/05
- [PATCH 2/6] usb-storage: add commandlog property, Gerd Hoffmann, 2020/11/05
- [PATCH 1/6] usb-storage: switch trace events, Gerd Hoffmann, 2020/11/05
- [PATCH 4/6] usb-storage: fill csw on cancel, Gerd Hoffmann, 2020/11/05
- [PATCH 6/6] xhci: move sanity checks,
Gerd Hoffmann <=
- [PATCH 3/6] usb-storage: use bool for removable property, Gerd Hoffmann, 2020/11/05
- [PATCH 5/6] xhci: fix guest triggerable assert, Gerd Hoffmann, 2020/11/05