usb_midi: Fix an error when unpluging a MIDI device

- It appears that, in this case, port->open_fd is NULL.
    Maybe, this would require some investigation too.
    But in this case, i think it is better to remove port
    from the device list anyway because remove_port will freed
    the port at the end of the loop.
    And adding 0xdeadbeef in the device list is not a good idea.

Change-Id: Id6b55f5e19ebbbbb48f0fa0b7d9ac65b996dbaf2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1746
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
oco27
2019-08-30 19:21:09 +00:00
committed by Adrien Destugues
parent df6cc9b5c9
commit fea647905f
@@ -464,8 +464,8 @@ usb_midi_removed(void* cookie)
break;
midiDevice->ports[cable] = NULL;
DPRINTF_DEBUG((MY_ID "removing port %d\n", cable));
remove_port_info(port);
if (port->open_fd != NULL) {
remove_port_info(port);
port->open_fd->port = NULL;
port->open_fd->device = NULL;
delete_sem(port->open_fd->sem_cb);