usb_midi: KDL when receiving data on a closed port

In normal situations the midi_server opens all midi ports, so this
wouldn't be a problem. However, my new MIDI keyboard (Miditech
i²Control-25) sends some MIDI events immediately when it is connected to
an USB port. These would be handled before the MIDI server had a chance
to open the port, leading to a KDL.

A similar problem could be triggered by killing the midi_server then
sending MIDI events from any other USB device.
This commit is contained in:
Adrien Destugues 2015-01-30 21:54:37 +01:00
parent 39a1cc8ec3
commit af3185c4b5

View File

@ -213,6 +213,9 @@ interpret_midi_buffer(usbmidi_device_info* midiDevice)
if (port == NULL) {
DPRINTF_ERR((MY_ID "no port matching cable number %d!\n",
packet->cn));
} else if (port->open_fd == NULL) {
DPRINTF_ERR((MY_ID "received data for port %d but it is closed!\n",
packet->cn));
} else {
ring_buffer_write(port->rbuf, packet->midi, pktlen);
release_sem_etc(port->open_fd->sem_cb, pktlen,