Skip to contentSkip to conversation

xhci: Fix possible side effect from assert()

PATCH New Alexey Kardashevskiy 1 participant 1 message Jul 18, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xhci: Fix possible side effect from assert()

A static analysis tool called BEAM detected possible side effect from assert() calling a helper which may change an XHCI ring after every call.

This moves xhci_ring_fetch() out of assert() so it will be called with and without enabled debug.

---
 hw/usb/hcd-xhci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/usb/hcd-xhci.c +3 -1
index 976bfb0..188f954 100644
@@ -2201,7 +2201,9 @@ static void xhci_kick_ep(XHCIState *xhci, unsigned int slotid,
         xfer->trb_count = length;
 
         for (i = 0; i < length; i++) {
-            assert(xhci_ring_fetch(xhci, ring, &xfer->trbs[i], NULL));
+            TRBType type;
+            type = xhci_ring_fetch(xhci, ring, &xfer->trbs[i], NULL);
+            assert(type);
         }
         xfer->streamid = streamid;
 
Signature · 1 line
2.5.0.rc3