Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/kraxel/tags/usb-20190829-pull-r…
Browse files Browse the repository at this point in the history
…equest' 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>
  • Loading branch information
pm215 committed Sep 4, 2019
2 parents 3b3f064 + e4c1c64 commit 03a6190
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
38 changes: 24 additions & 14 deletions hw/usb/dev-mtp.c
Expand Up @@ -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");
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 ((s->root == NULL) || !g_path_is_absolute(s->root)) {
error_setg(errp, "usb-mtp: rootdir must be configured and be an absolute path");
return;
}

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 = {
Expand Down
2 changes: 2 additions & 0 deletions hw/usb/hcd-xhci.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 03a6190

Please sign in to comment.