From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>
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 [thread overview]
Message-ID: <20190402064639.27108-3-kraxel@redhat.com> (raw)
In-Reply-To: <20190402064639.27108-1-kraxel@redhat.com>
From: Peter Maydell <peter.maydell@linaro.org>
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 <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20190328133503.6490-1-peter.maydell@linaro.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
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
next prev parent reply other threads:[~2019-04-02 7:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-02 6:46 [Qemu-devel] [PULL 0/5] Fixes 20190402 patches Gerd Hoffmann
2019-04-02 6:46 ` [Qemu-devel] [PULL 1/5] Revert "audio: fix pc speaker init" Gerd Hoffmann
2019-04-02 6:46 ` Gerd Hoffmann [this message]
2019-04-02 6:46 ` [Qemu-devel] [PULL 3/5] usb-mtp: fix return status of delete Gerd Hoffmann
2019-04-02 6:46 ` [Qemu-devel] [PULL 4/5] usb-mtp: remove usb_mtp_object_free_one Gerd Hoffmann
2019-04-02 6:46 ` [Qemu-devel] [PULL 5/5] audio: fix audio timer rate conversion bug Gerd Hoffmann
2019-04-02 8:33 ` [Qemu-devel] [PULL 0/5] Fixes 20190402 patches Peter Maydell
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=20190402064639.27108-3-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=peter.maydell@linaro.org \
--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).