qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL 2/5] hw/usb/bus.c: Handle "no speed matched" case in


From: Gerd Hoffmann
Subject: [Qemu-devel] [PULL 2/5] hw/usb/bus.c: Handle "no speed matched" case in usb_mask_to_str()
Date: Tue, 2 Apr 2019 08:46:36 +0200

From: Peter Maydell <address@hidden>

In usb_mask_to_str() we convert a mask of USB speeds into
a human-readable string (like "full+high") for use in
tracing and error messages. However the conversion code
doesn't do anything to the string buffer if the passed in
speedmask doesn't match any of the recognized speeds,
which means that the tracing and error messages will
end up with random garbage in them. This can happen if
we're doing USB device passthrough.

Handle the "unrecognized speed" case by using the
string "unknown".

Fixes: https://bugs.launchpad.net/qemu/+bug/1603785
Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-id: address@hidden
Signed-off-by: Gerd Hoffmann <address@hidden>
---
 hw/usb/bus.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 6fffab7bfa44..9a74dc956010 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -500,6 +500,10 @@ static void usb_mask_to_str(char *dest, size_t size,
                             speeds[i].name);
         }
     }
+
+    if (pos == 0) {
+        snprintf(dest, size, "unknown");
+    }
 }
 
 void usb_check_attach(USBDevice *dev, Error **errp)
-- 
2.18.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]