patch-2.2.3 linux/drivers/sound/sequencer.c

Next file: linux/drivers/sound/sonicvibes.c
Previous file: linux/drivers/sound/sb_mixer.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.2/linux/drivers/sound/sequencer.c linux/drivers/sound/sequencer.c
@@ -1105,7 +1105,7 @@
 		 */
 
 		for (i = 0; i < max_mididev; i++)
-			if (!midi_opened[i])
+			if (!midi_opened[i] && midi_devs[i])
 			{
 				if ((retval = midi_devs[i]->open(i, mode,
 					sequencer_midi_input, sequencer_midi_output)) >= 0)
@@ -1411,7 +1411,7 @@
 		case SNDCTL_SEQ_TESTMIDI:
 			if (__get_user(midi_dev, (int *)arg))
 				return -EFAULT;
-			if (midi_dev < 0 || midi_dev >= max_mididev)
+			if (midi_dev < 0 || midi_dev >= max_mididev || !midi_devs[midi_dev])
 				return -ENXIO;
 
 			if (!midi_opened[midi_dev] &&
@@ -1529,7 +1529,7 @@
 		case SNDCTL_MIDI_INFO:
 			if (get_user(dev, (int *)(&(((struct midi_info *)arg)->device))))
 				return -EFAULT;
-			if (dev < 0 || dev >= max_mididev)
+			if (dev < 0 || dev >= max_mididev || !midi_devs[dev])
 				return -ENXIO;
 			midi_devs[dev]->info.device = dev;
 			return copy_to_user(arg, &midi_devs[dev]->info, sizeof(struct midi_info))?-EFAULT:0;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)