From: Clemens Ladisch Date: Sun, 20 Nov 2005 12:59:56 +0000 (+0100) Subject: [ALSA] rawmidi: protect against invalid device number in snd_rawmidi_info_select() X-Git-Tag: v2.6.16-rc1~169^2~16^2~28^2~81 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a106cd3d9e88c8761bd0eac2ce402cc82bd11fea;p=profile%2Fivi%2Fkernel-adaptation-intel-automotive.git [ALSA] rawmidi: protect against invalid device number in snd_rawmidi_info_select() Modules: RawMidi Midlevel In snd_rawmidi_info_select(), check that the device identified by the passed device number actually exists. Signed-off-by: Clemens Ladisch --- diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 7a86a9a..d703545 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -573,6 +573,8 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info if (info->device >= SNDRV_RAWMIDI_DEVICES) return -ENXIO; rmidi = snd_rawmidi_devices[card->number * SNDRV_RAWMIDI_DEVICES + info->device]; + if (!rmidi) + return -ENXIO; if (info->stream < 0 || info->stream > 1) return -EINVAL; pstr = &rmidi->streams[info->stream];