Skip to contentSkip to conversation

usb-audio: ignore usb packages with wrong size

PATCH In review Gerd Hoffmann 2 participants 2 messages Dec 11, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb-audio: ignore usb packages with wrong size

usb packets with no payload (zero length) seem to happen in practice for whatever reason. Add a check and skip the packet then, otherwise we'll trigger an assert.

---
 hw/usb/dev-audio.c | 3 +++
 1 file changed, 3 insertions(+)
hw/usb/dev-audio.c +3 -0
index ee43e4914d..28ac7c5165 100644
@@ -321,6 +321,9 @@ static int streambuf_put(struct streambuf *buf, USBPacket *p)
     if (!free) {
         return 0;
     }
+    if (p->iov.size != USBAUDIO_PACKET_SIZE) {
+        return 0;
+    }
     assert(free >= USBAUDIO_PACKET_SIZE);
     usb_packet_copy(p, buf->data + (buf->prod % buf->size),
                     USBAUDIO_PACKET_SIZE);
Signature · 1 line
2.9.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Gerd Hoffmann

usb packets with no payload (zero length) seem to happen in practice for whatever reason. Add a check and skip the packet then, otherwise we'll trigger an assert.

Quoted 19 lines
---
 hw/usb/dev-audio.c | 3 +++
 1 file changed, 3 insertions(+)
hw/usb/dev-audio.c +3 -0
index ee43e4914d..28ac7c5165 100644
@@ -321,6 +321,9 @@ static int streambuf_put(struct streambuf *buf, USBPacket *p)
     if (!free) {
         return 0;
     }
+    if (p->iov.size != USBAUDIO_PACKET_SIZE) {
+        return 0;
+    }
     assert(free >= USBAUDIO_PACKET_SIZE);
     usb_packet_copy(p, buf->data + (buf->prod % buf->size),
                     USBAUDIO_PACKET_SIZE);