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:
parent
b80428abf6
commit
ee804a84fa
|
@ -228,10 +228,19 @@ struct Usb_host_device : List<Usb_host_device>::Element
|
||||||
|
|
||||||
Usb::Packet_descriptor alloc_packet(int length)
|
Usb::Packet_descriptor alloc_packet(int length)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!usb_raw.source()->ready_to_submit())
|
if (!usb_raw.source()->ready_to_submit())
|
||||||
throw -1;
|
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);
|
Usb::Packet_descriptor packet = usb_raw.source()->alloc_packet(length);
|
||||||
packet.completion = alloc_completion();
|
packet.completion = alloc_completion();
|
||||||
return packet;
|
return packet;
|
||||||
|
|
|
@ -85,6 +85,16 @@ class Usb::Packet_handler
|
||||||
throw Usb::Session::Tx::Source::Packet_alloc_failed();
|
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) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
Packet_descriptor p = _connection.source()->alloc_packet(size);
|
Packet_descriptor p = _connection.source()->alloc_packet(size);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user