mirror of
https://github.com/mii443/qemu.git
synced 2025-12-09 22:18:23 +00:00
Merge remote-tracking branch 'remotes/kraxel/tags/usb-20180507-pull-request' into staging
usb: fixes for mtp and host. # gpg: Signature made Mon 07 May 2018 10:44:26 BST # gpg: using RSA key 4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/usb-20180507-pull-request: usb-host: skip open on pending postload bh usb-mtp: Unconditionally check for the readonly bit usb-mtp: Add some NULL checks for issues pointed out by coverity Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
@@ -1446,8 +1446,7 @@ static void usb_mtp_command(MTPState *s, MTPControl *c)
|
|||||||
if (o == NULL) {
|
if (o == NULL) {
|
||||||
usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE, c->trans,
|
usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE, c->trans,
|
||||||
0, 0, 0, 0);
|
0, 0, 0, 0);
|
||||||
}
|
} else if (o->format != FMT_ASSOCIATION) {
|
||||||
if (o->format != FMT_ASSOCIATION) {
|
|
||||||
usb_mtp_queue_result(s, RES_INVALID_PARENT_OBJECT, c->trans,
|
usb_mtp_queue_result(s, RES_INVALID_PARENT_OBJECT, c->trans,
|
||||||
0, 0, 0, 0);
|
0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -1660,6 +1659,7 @@ static void usb_mtp_write_metadata(MTPState *s)
|
|||||||
uint32_t next_handle = s->next_handle;
|
uint32_t next_handle = s->next_handle;
|
||||||
|
|
||||||
assert(!s->write_pending);
|
assert(!s->write_pending);
|
||||||
|
assert(p != NULL);
|
||||||
|
|
||||||
utf16_to_str(dataset->length, dataset->filename, filename);
|
utf16_to_str(dataset->length, dataset->filename, filename);
|
||||||
|
|
||||||
@@ -1838,7 +1838,7 @@ static void usb_mtp_handle_data(USBDevice *dev, USBPacket *p)
|
|||||||
p->status = USB_RET_STALL;
|
p->status = USB_RET_STALL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (s->data_out && !s->data_out->first) {
|
if ((s->data_out != NULL) && !s->data_out->first) {
|
||||||
container_type = TYPE_DATA;
|
container_type = TYPE_DATA;
|
||||||
} else {
|
} else {
|
||||||
usb_packet_copy(p, &container, sizeof(container));
|
usb_packet_copy(p, &container, sizeof(container));
|
||||||
@@ -1948,16 +1948,17 @@ static void usb_mtp_realize(USBDevice *dev, Error **errp)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
s->desc = strrchr(s->root, '/');
|
s->desc = strrchr(s->root, '/');
|
||||||
/* Mark store as RW */
|
|
||||||
if (!s->readonly) {
|
|
||||||
s->flags |= (1 << MTP_FLAG_WRITABLE);
|
|
||||||
}
|
|
||||||
if (s->desc && s->desc[0]) {
|
if (s->desc && s->desc[0]) {
|
||||||
s->desc = g_strdup(s->desc + 1);
|
s->desc = g_strdup(s->desc + 1);
|
||||||
} else {
|
} else {
|
||||||
s->desc = g_strdup("none");
|
s->desc = g_strdup("none");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Mark store as RW */
|
||||||
|
if (!s->readonly) {
|
||||||
|
s->flags |= (1 << MTP_FLAG_WRITABLE);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const VMStateDescription vmstate_usb_mtp = {
|
static const VMStateDescription vmstate_usb_mtp = {
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ struct USBHostDevice {
|
|||||||
/* callbacks & friends */
|
/* callbacks & friends */
|
||||||
QEMUBH *bh_nodev;
|
QEMUBH *bh_nodev;
|
||||||
QEMUBH *bh_postld;
|
QEMUBH *bh_postld;
|
||||||
|
bool bh_postld_pending;
|
||||||
Notifier exit;
|
Notifier exit;
|
||||||
|
|
||||||
/* request queues */
|
/* request queues */
|
||||||
@@ -870,6 +871,10 @@ static int usb_host_open(USBHostDevice *s, libusb_device *dev)
|
|||||||
int rc;
|
int rc;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
|
if (s->bh_postld_pending) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
trace_usb_host_open_started(bus_num, addr);
|
trace_usb_host_open_started(bus_num, addr);
|
||||||
|
|
||||||
if (s->dh != NULL) {
|
if (s->dh != NULL) {
|
||||||
@@ -1528,6 +1533,7 @@ static void usb_host_post_load_bh(void *opaque)
|
|||||||
if (udev->attached) {
|
if (udev->attached) {
|
||||||
usb_device_detach(udev);
|
usb_device_detach(udev);
|
||||||
}
|
}
|
||||||
|
dev->bh_postld_pending = false;
|
||||||
usb_host_auto_check(NULL);
|
usb_host_auto_check(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1539,6 +1545,7 @@ static int usb_host_post_load(void *opaque, int version_id)
|
|||||||
dev->bh_postld = qemu_bh_new(usb_host_post_load_bh, dev);
|
dev->bh_postld = qemu_bh_new(usb_host_post_load_bh, dev);
|
||||||
}
|
}
|
||||||
qemu_bh_schedule(dev->bh_postld);
|
qemu_bh_schedule(dev->bh_postld);
|
||||||
|
dev->bh_postld_pending = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user