From fea647905ffbb7650c1f7c1c12852184a2606e19 Mon Sep 17 00:00:00 2001 From: oco27 Date: Sun, 25 Aug 2019 16:45:14 +0200 Subject: [PATCH] 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 --- src/add-ons/kernel/drivers/midi/usb_midi/usb_midi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/add-ons/kernel/drivers/midi/usb_midi/usb_midi.cpp b/src/add-ons/kernel/drivers/midi/usb_midi/usb_midi.cpp index 589905ef93..5656fec2c8 100644 --- a/src/add-ons/kernel/drivers/midi/usb_midi/usb_midi.cpp +++ b/src/add-ons/kernel/drivers/midi/usb_midi/usb_midi.cpp @@ -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);