From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933598AbWKWLG3 (ORCPT ); Thu, 23 Nov 2006 06:06:29 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S933600AbWKWLG3 (ORCPT ); Thu, 23 Nov 2006 06:06:29 -0500 Received: from mx2.suse.de ([195.135.220.15]:46529 "EHLO mx2.suse.de") by vger.kernel.org with ESMTP id S933598AbWKWLG2 (ORCPT ); Thu, 23 Nov 2006 06:06:28 -0500 Date: Thu, 23 Nov 2006 12:06:26 +0100 Message-ID: From: Takashi Iwai To: Akinobu Mita Cc: linux-kernel@vger.kernel.org, Jaroslav Kysela Subject: Re: [PATCH] sound: initialize rawmidi substream list In-Reply-To: <20061122185045.GE2985@APFDCB5C> References: <20061122185045.GE2985@APFDCB5C> User-Agent: Wanderlust/2.12.0 (Your Wildest Dreams) SEMI/1.14.6 (Maruoka) FLIM/1.14.7 (=?ISO-8859-4?Q?Sanj=F2?=) APEL/10.6 MULE XEmacs/21.5 (beta27) (fiddleheads) (+CVS-20060704) (i386-suse-linux) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org At Thu, 23 Nov 2006 03:50:45 +0900, Akinobu Mita wrote: > > 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. > > Cc: Takashi Iwai > Cc: Jaroslav Kysela > Signed-off-by: Akinobu Mita Thanks, merged to ALSA tree. Takashi > > sound/core/rawmidi.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > Index: work-fault-inject/sound/core/rawmidi.c > =================================================================== > --- work-fault-inject.orig/sound/core/rawmidi.c > +++ work-fault-inject/sound/core/rawmidi.c > @@ -1379,7 +1379,6 @@ static int snd_rawmidi_alloc_substreams( > 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) { > @@ -1434,6 +1433,9 @@ int snd_rawmidi_new(struct snd_card *car > 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, >