Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934272AbXHGNan (ORCPT ); Tue, 7 Aug 2007 09:30:43 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758760AbXHGNag (ORCPT ); Tue, 7 Aug 2007 09:30:36 -0400 Received: from ns2.suse.de ([195.135.220.15]:60147 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752894AbXHGNaf (ORCPT ); Tue, 7 Aug 2007 09:30:35 -0400 Date: Tue, 07 Aug 2007 15:30:33 +0200 Message-ID: From: Takashi Iwai To: Eugene Teo Cc: linux-kernel@vger.kernel.org Subject: Re: [ALSA] seq: resource leak fix and various code cleanups In-Reply-To: <20070807105249.GA4702@kernel.sg> References: <20070807084048.GA5205@kernel.sg> <20070807105249.GA4702@kernel.sg> User-Agent: Wanderlust/2.15.5 (Almost Unreal) 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 Content-Length: 1772 Lines: 58 At Tue, 7 Aug 2007 18:52:49 +0800, Eugene Teo wrote: > > diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c > index ca5a2ed..f26b751 100644 > --- a/sound/core/seq/oss/seq_oss_init.c > +++ b/sound/core/seq/oss/seq_oss_init.c > @@ -176,29 +176,31 @@ snd_seq_oss_open(struct file *file, int level) > int i, rc; > struct seq_oss_devinfo *dp; > > - if ((dp = kzalloc(sizeof(*dp), GFP_KERNEL)) == NULL) { > + dp = kzalloc(sizeof(*dp), GFP_KERNEL); > + if (!dp) { > snd_printk(KERN_ERR "can't malloc device info\n"); > return -ENOMEM; > } > debug_printk(("oss_open: dp = %p\n", dp)); > > + dp->cseq = system_client; > + dp->port = -1; > + dp->queue = -1; > + dp->readq = NULL; > + dp->writeq = NULL; NULL initialization is redundant, as it's kzalloced. > @@ -235,7 +239,8 @@ snd_seq_oss_open(struct file *file, int level) > /* initialize read queue */ > debug_printk(("initialize read queue\n")); > if (is_read_mode(dp->file_mode)) { > - if ((dp->readq = snd_seq_oss_readq_new(dp, maxqlen)) == NULL) { > + dp->readq = snd_seq_oss_readq_new(dp, maxqlen); > + if (dp->readq == NULL) { "if (!dp->readq)" is preferred. > @@ -253,7 +258,8 @@ snd_seq_oss_open(struct file *file, int level) > > /* initialize timer */ > debug_printk(("initialize timer\n")); > - if ((dp->timer = snd_seq_oss_timer_new(dp)) == NULL) { > + dp->timer = snd_seq_oss_timer_new(dp); > + if (dp->timer == NULL) { Ditto. I fixed these and applied your patch to ALSA tree now. Thanks! Takashi - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/