struct buf_packet *bulkp;
int count;
+ assert(maxp != 0);
while ((bulkp = QTAILQ_FIRST(&dev->endpoint[EP2I(ep)].bufpq)) &&
p->actual_length < p->iov.size && p->status == USB_RET_SUCCESS) {
if (bulkp->len < 2) {
.stream_id = 0,
.no_transfers = 5,
};
+ assert(dev->endpoint[EP2I(ep)].max_packet_size != 0);
/* Round bytes_per_transfer up to a multiple of max_packet_size */
bpt = 512 + dev->endpoint[EP2I(ep)].max_packet_size - 1;
bpt /= dev->endpoint[EP2I(ep)].max_packet_size;
}
if (dev->endpoint[EP2I(ep)].bulk_receiving_enabled) {
+ assert(maxp != 0);
if (size != 0 && (size % maxp) == 0) {
usbredir_handle_buffered_bulk_in_data(dev, p, ep);
return;
if (usbredirparser_peer_has_cap(dev->parser,
usb_redir_cap_ep_info_max_packet_size)) {
dev->endpoint[i].max_packet_size = ep_info->max_packet_size[i];
+ if (ep_info->max_packet_size[i] == 0 &&
+ dev->endpoint[i].bulk_receiving_enabled) {
+ USBPacket *p = dev->endpoint[i].pending_async_packet;
+ usbredir_stop_bulk_receiving(dev, I2EP(i));
+ dev->endpoint[i].bulk_receiving_enabled = 0;
+ if (p != NULL) {
+ dev->endpoint[i].pending_async_packet = NULL;
+ p->status = USB_RET_IOERROR;
+ usb_packet_complete(&dev->dev, p);
+ }
+ }
}
#if USBREDIR_VERSION >= 0x000700
if (usbredirparser_peer_has_cap(dev->parser,
}
/* Data must be in maxp chunks for buffered_bulk_add_*_data_to_packet */
+ assert(dev->endpoint[EP2I(ep)].max_packet_size != 0);
len = dev->endpoint[EP2I(ep)].max_packet_size;
status = usb_redir_success;
free_on_destroy = NULL;
usbredir_setup_usb_eps(dev);
usbredir_check_bulk_receiving(dev);
+ for (int i = 0; i < MAX_ENDPOINTS; i++) {
+ if (dev->endpoint[i].bulk_receiving_started &&
+ dev->endpoint[i].max_packet_size == 0) {
+ error_report("usbredir: endpoint %d has bulk receiving started "
+ "with zero max_packet_size", i);
+ return -EINVAL;
+ }
+ }
+
return 0;
}