summaryrefslogtreecommitdiff
path: root/hw/usb/dev-smartcard-reader.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/usb/dev-smartcard-reader.c')
-rw-r--r--hw/usb/dev-smartcard-reader.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index cabb564788..f7451923f4 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -1064,7 +1064,8 @@ err:
return;
}
-static void ccid_bulk_in_copy_to_guest(USBCCIDState *s, USBPacket *p)
+static void ccid_bulk_in_copy_to_guest(USBCCIDState *s, USBPacket *p,
+ unsigned int max_packet_size)
{
int len = 0;
@@ -1072,10 +1073,13 @@ static void ccid_bulk_in_copy_to_guest(USBCCIDState *s, USBPacket *p)
if (s->current_bulk_in != NULL) {
len = MIN(s->current_bulk_in->len - s->current_bulk_in->pos,
p->iov.size);
- usb_packet_copy(p, s->current_bulk_in->data +
- s->current_bulk_in->pos, len);
+ if (len) {
+ usb_packet_copy(p, s->current_bulk_in->data +
+ s->current_bulk_in->pos, len);
+ }
s->current_bulk_in->pos += len;
- if (s->current_bulk_in->pos == s->current_bulk_in->len) {
+ if (s->current_bulk_in->pos == s->current_bulk_in->len
+ && len != max_packet_size) {
ccid_bulk_in_release(s);
}
} else {
@@ -1107,7 +1111,7 @@ static void ccid_handle_data(USBDevice *dev, USBPacket *p)
case USB_TOKEN_IN:
switch (p->ep->nr) {
case CCID_BULK_IN_EP:
- ccid_bulk_in_copy_to_guest(s, p);
+ ccid_bulk_in_copy_to_guest(s, p, dev->ep_ctl.max_packet_size);
break;
case CCID_INT_IN_EP:
if (s->notify_slot_change) {