mirror of https://gitee.com/openkylin/qemu.git
usb-ccid: better bulk_out error handling
Add err goto label where we can jump to from all error conditions. STALL request on all errors. Reset position on all errors. Normal request processing is not in a else branch any more, so this code is reintended, there are no code changes in that part of the code though. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 1487250819-23764-2-git-send-email-kraxel@redhat.com
This commit is contained in:
parent
558ff1b6ef
commit
0aeebc73b7
|
@ -1001,8 +1001,7 @@ static void ccid_handle_bulk_out(USBCCIDState *s, USBPacket *p)
|
||||||
CCID_Header *ccid_header;
|
CCID_Header *ccid_header;
|
||||||
|
|
||||||
if (p->iov.size + s->bulk_out_pos > BULK_OUT_DATA_SIZE) {
|
if (p->iov.size + s->bulk_out_pos > BULK_OUT_DATA_SIZE) {
|
||||||
p->status = USB_RET_STALL;
|
goto err;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
ccid_header = (CCID_Header *)s->bulk_out_data;
|
ccid_header = (CCID_Header *)s->bulk_out_data;
|
||||||
usb_packet_copy(p, s->bulk_out_data + s->bulk_out_pos, p->iov.size);
|
usb_packet_copy(p, s->bulk_out_data + s->bulk_out_pos, p->iov.size);
|
||||||
|
@ -1017,7 +1016,9 @@ static void ccid_handle_bulk_out(USBCCIDState *s, USBPacket *p)
|
||||||
DPRINTF(s, 1,
|
DPRINTF(s, 1,
|
||||||
"%s: bad USB_TOKEN_OUT length, should be at least 10 bytes\n",
|
"%s: bad USB_TOKEN_OUT length, should be at least 10 bytes\n",
|
||||||
__func__);
|
__func__);
|
||||||
} else {
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
DPRINTF(s, D_MORE_INFO, "%s %x %s\n", __func__,
|
DPRINTF(s, D_MORE_INFO, "%s %x %s\n", __func__,
|
||||||
ccid_header->bMessageType,
|
ccid_header->bMessageType,
|
||||||
ccid_message_type_to_str(ccid_header->bMessageType));
|
ccid_message_type_to_str(ccid_header->bMessageType));
|
||||||
|
@ -1073,8 +1074,13 @@ static void ccid_handle_bulk_out(USBCCIDState *s, USBPacket *p)
|
||||||
ccid_write_slot_status(s, ccid_header);
|
ccid_write_slot_status(s, ccid_header);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
s->bulk_out_pos = 0;
|
s->bulk_out_pos = 0;
|
||||||
|
return;
|
||||||
|
|
||||||
|
err:
|
||||||
|
p->status = USB_RET_STALL;
|
||||||
|
s->bulk_out_pos = 0;
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in New Issue