Skip to content

Commit b826fb8

Browse files
committed
Merge remote-tracking branch 'remotes/kraxel/tags/usb-20210218-pull-request' into staging
usb: two bugfixes. # gpg: Signature made Thu 18 Feb 2021 11:51:44 GMT # gpg: using RSA key A0328CFFB93A17A79901FE7D4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <[email protected]>" [full] # gpg: aka "Gerd Hoffmann <[email protected]>" [full] # gpg: aka "Gerd Hoffmann (private) <[email protected]>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/usb-20210218-pull-request: usb/pcap: set flag_setup usb-host: use correct altsetting in usb_host_ep_update Signed-off-by: Peter Maydell <[email protected]>
2 parents 91416a4 + 6ba5a43 commit b826fb8

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

hw/usb/host-libusb.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ static void usb_host_ep_update(USBHostDevice *s)
836836
struct libusb_ss_endpoint_companion_descriptor *endp_ss_comp;
837837
#endif
838838
uint8_t devep, type;
839-
int pid, ep;
839+
int pid, ep, alt;
840840
int rc, i, e;
841841

842842
usb_ep_reset(udev);
@@ -848,8 +848,20 @@ static void usb_host_ep_update(USBHostDevice *s)
848848
conf->bConfigurationValue, true);
849849

850850
for (i = 0; i < conf->bNumInterfaces; i++) {
851-
assert(udev->altsetting[i] < conf->interface[i].num_altsetting);
852-
intf = &conf->interface[i].altsetting[udev->altsetting[i]];
851+
/*
852+
* The udev->altsetting array indexes alternate settings
853+
* by the interface number. Get the 0th alternate setting
854+
* first so that we can grab the interface number, and
855+
* then correct the alternate setting value if necessary.
856+
*/
857+
intf = &conf->interface[i].altsetting[0];
858+
alt = udev->altsetting[intf->bInterfaceNumber];
859+
860+
if (alt != 0) {
861+
assert(alt < conf->interface[i].num_altsetting);
862+
intf = &conf->interface[i].altsetting[alt];
863+
}
864+
853865
trace_usb_host_parse_interface(s->bus_num, s->addr,
854866
intf->bInterfaceNumber,
855867
intf->bAlternateSetting, true);

hw/usb/pcap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ static void do_usb_pcap_ctrl(FILE *fp, USBPacket *p, bool setup)
127127
.xfer_type = usbmon_xfer_type[USB_ENDPOINT_XFER_CONTROL],
128128
.epnum = in ? 0x80 : 0,
129129
.devnum = dev->addr,
130+
.flag_setup = setup ? 0 : '-',
130131
.flag_data = '=',
131132
.length = dev->setup_len,
132133
};
@@ -169,6 +170,7 @@ static void do_usb_pcap_data(FILE *fp, USBPacket *p, bool setup)
169170
.xfer_type = usbmon_xfer_type[p->ep->type],
170171
.epnum = usbmon_epnum(p),
171172
.devnum = p->ep->dev->addr,
173+
.flag_setup = '-',
172174
.flag_data = '=',
173175
.length = p->iov.size,
174176
};

0 commit comments

Comments
 (0)