Re: [ALSA] seq: resource leak fix and various code cleanups

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux