usb: bugfixes for xhci and mtp.

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJdZ3pNAAoJEEy22O7T6HE41r8QALxaWj0aknOeN5kzEnBZviOF
 T+L7PNxw7zWy31RPtYNAmuwINmaGeAiCQhIzj/5rNuKi5Vw+7JiFLPI4ql4K4jN4
 6XL80aL14kYDGQPjTXzgzkNcgin+SBjzNk8xnX6TAET+DDoNcoh1imSnXmWjq8Cr
 PyKsC3jBPSpzmar2OgUUVH1Bior+1mMtsOF7dC3Dp6q0j6hLVvyNHaBC7PYeEFlo
 j2Z5q7YOplEyvEhV7r6/iZYLdEmBol0pe9BmAKWl/WLO8u1xcOpi0ENNPAV4oPid
 Cuc3NiqtJ4VPQLVsLwLCGB4M61yNbM+DHVX/7+wpIycZpTrJuvndECoxvMxrjLY2
 3Jkyj6FoGl8tbgbC9zga/b/RZ5pfgE6qlw+H/vYNnyYOaWUDN9dV1qUydldYmrpf
 gVMAGg48pOutIgFBiJ9Y3+2hx30Y09JWUmHq4SsTvGHVSjRDFmPKiU8bRQChKhEi
 Nk/ax8Sg96RmylUGKkFQ0FvgJBiIXo+iVyrMUgeHz9w2qi/WzBvwqvfTJoo56opt
 kyOeYzz4q96HVC34E/nbClQnvhwye6HG/47tFmi85/+oH4rfOZcX/uZ+jjIyXYFl
 kNVQJYJi5QKLqfonfeBvLgiry1s0Yda1IuyaRq5JX+IjFWQihh1bHvgmS4ko0IZS
 oiv/f5p7uS9tdSGcL7h3
 =z9ow
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kraxel/tags/usb-20190829-pull-request' into staging

usb: bugfixes for xhci and mtp.

# gpg: Signature made Thu 29 Aug 2019 08:10:05 BST
# gpg:                using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full]
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>" [full]
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full]
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/usb-20190829-pull-request:
  usb-mtp: add sanity checks on rootdir
  xhci: Fix memory leak in xhci_kick_epctx
  xhci: Fix memory leak in xhci_address_slot

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2019-09-04 09:17:17 +01:00
commit 03a6190518
2 changed files with 26 additions and 14 deletions

View File

@ -2038,26 +2038,36 @@ static void usb_mtp_realize(USBDevice *dev, Error **errp)
{
MTPState *s = USB_MTP(dev);
usb_desc_create_serial(dev);
usb_desc_init(dev);
QTAILQ_INIT(&s->objects);
if (s->desc == NULL) {
if (s->root == NULL) {
error_setg(errp, "usb-mtp: rootdir property must be configured");
if ((s->root == NULL) || !g_path_is_absolute(s->root)) {
error_setg(errp, "usb-mtp: rootdir must be configured and be an absolute path");
return;
}
s->desc = strrchr(s->root, '/');
if (s->desc && s->desc[0]) {
s->desc = g_strdup(s->desc + 1);
} else {
s->desc = g_strdup("none");
}
if (access(s->root, R_OK) != 0) {
error_setg(errp, "usb-mtp: rootdir does not exist/not readable");
return;
} else if (!s->readonly && access(s->root, W_OK) != 0) {
error_setg(errp, "usb-mtp: rootdir does not have write permissions");
return;
}
/* Mark store as RW */
if (!s->readonly) {
s->flags |= (1 << MTP_FLAG_WRITABLE);
}
if (s->desc == NULL) {
/*
* This does not check if path exists
* but we have the checks above
*/
s->desc = g_path_get_basename(s->root);
}
usb_desc_create_serial(dev);
usb_desc_init(dev);
QTAILQ_INIT(&s->objects);
}
static const VMStateDescription vmstate_usb_mtp = {

View File

@ -1914,6 +1914,7 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid)
}
usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);
if (xfer->packet.status == USB_RET_NAK) {
xhci_xfer_unmap(xfer);
return;
}
xhci_try_complete_packet(xfer);
@ -2161,6 +2162,7 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid,
DeviceOutRequest | USB_REQ_SET_ADDRESS,
slotid, 0, 0, NULL);
assert(p.status != USB_RET_ASYNC);
usb_packet_cleanup(&p);
}
res = xhci_enable_ep(xhci, slotid, 1, octx+32, ep0_ctx);