usb: do not allocate raw packets without size

Allocating a packet in the packet stream without a payload is not
allowed. Therefore we have to allocate CTRL message packets, that do
not have a payload, with a bogus length instead.
This commit is contained in:
Josef Söntgen 2016-05-26 11:46:49 +02:00 committed by Christian Helmuth
parent b80428abf6
commit ee804a84fa
2 changed files with 20 additions and 1 deletions

View File

@ -228,10 +228,19 @@ struct Usb_host_device : List<Usb_host_device>::Element
Usb::Packet_descriptor alloc_packet(int length)
{
if (!usb_raw.source()->ready_to_submit())
throw -1;
if (length <= 0) {
/*
* XXX Packets without payload are not supported by the packet stream
* currently. Therefore, we use a (small) bogus length
* here and depend on the USB driver to handle this case
* correctly.
*/
length = 4;
}
Usb::Packet_descriptor packet = usb_raw.source()->alloc_packet(length);
packet.completion = alloc_completion();
return packet;

View File

@ -85,6 +85,16 @@ class Usb::Packet_handler
throw Usb::Session::Tx::Source::Packet_alloc_failed();
}
if (size == 0) {
/*
* XXX Packets without payload are not supported by the packet
* stream currently. Therefore, we use a (small) bogus
* length here and depend on the USB driver to handle this
* case correctly.
*/
size = 4;
}
while (true) {
try {
Packet_descriptor p = _connection.source()->alloc_packet(size);