]> err.no Git - linux-2.6/commitdiff
[ALSA] sound: initialize rawmidi substream list
authorAkinobu Mita <akinobu.mita@gmail.com>
Thu, 23 Nov 2006 11:02:33 +0000 (12:02 +0100)
committerJaroslav Kysela <perex@server.perex.cz>
Wed, 20 Dec 2006 07:55:59 +0000 (08:55 +0100)
If snd_rawmidi_new() failed to allocate substreams for input
(snd_rawmidi_alloc_substreams() failed to populate a
&rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT]), it will try to
free rawmidi instance by snd_rawmidi_free().
But it will cause oops because snd_rawmidi_free() tries to free
both of substreams list but list for output
(&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT]) is not initialized yet.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
sound/core/rawmidi.c

index 269c467ca9bb2ba76f3c001f1d824414ccb5bd07..0f055bfcbdac3b305e78c80fc6f0f01e0d21f56c 100644 (file)
@@ -1385,7 +1385,6 @@ static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi,
        struct snd_rawmidi_substream *substream;
        int idx;
 
-       INIT_LIST_HEAD(&stream->substreams);
        for (idx = 0; idx < count; idx++) {
                substream = kzalloc(sizeof(*substream), GFP_KERNEL);
                if (substream == NULL) {
@@ -1440,6 +1439,9 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device,
        rmidi->device = device;
        mutex_init(&rmidi->open_mutex);
        init_waitqueue_head(&rmidi->open_wait);
+       INIT_LIST_HEAD(&rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams);
+       INIT_LIST_HEAD(&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams);
+
        if (id != NULL)
                strlcpy(rmidi->id, id, sizeof(rmidi->id));
        if ((err = snd_rawmidi_alloc_substreams(rmidi,