mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Eugene Teo <eugeneteo@kernel.sg>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [ALSA] seq: resource leak fix and various code cleanups
Date: Tue, 07 Aug 2007 15:30:33 +0200	[thread overview]
Message-ID: <s5hd4xz1ngm.wl%tiwai@suse.de> (raw)
In-Reply-To: <20070807105249.GA4702@kernel.sg>

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

  reply	other threads:[~2007-08-07 13:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-07  8:40 Eugene Teo
2007-08-07  9:43 ` Takashi Iwai
2007-08-07 10:52   ` Eugene Teo
2007-08-07 13:30     ` Takashi Iwai [this message]
2007-08-07 13:43       ` Eugene Teo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hd4xz1ngm.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=eugeneteo@kernel.sg \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®