Skip to contentSkip to conversation

Midi close race

PATCH New Adrian Cox 1 participant 1 message Sep 21, 2001

lore
Share & tools
lore

Adrian Cox

author
#0 lore raw

PATCH 1/1 Midi close race

The patch below fixes a race condition when closing the MIDI input device. The previous code left the timer running while freeing buffers used by the timer routine, leading to frequent OOPSes. Thomas: you seem to have been the last person to touch this file. Any comments?

drivers/sound/midibuf.c +3 -3
@@ -253,13 +253,13 @@
 
 	midi_devs[dev]->close(dev);
 
+	if (open_devs < 2)
+		del_timer(&poll_timer);
+	open_devs--;
 	vfree(midi_in_buf[dev]);
 	vfree(midi_out_buf[dev]);
 	midi_in_buf[dev] = NULL;
 	midi_out_buf[dev] = NULL;
-	if (open_devs < 2)
-		del_timer(&poll_timer);;
-	open_devs--;
 
 	if (midi_devs[dev]->owner)
 		__MOD_DEC_USE_COUNT (midi_devs[dev]->owner);