Subject: Re: inbalanced ioremap/iounmap? in cpm_pic_init(); arch/powerpc/sysdev/commproc.c

From: Scott Wood <[email-masked]>
Date: Thu, 8 Nov 2007 10:55:08 -0600

On Wed, Nov 07, 2007 at 11:01:42PM +0100, Roel Kluin wrote:
> It appears to me that ioremap/iounmap in cpm_pic_init() is imbalanced. I
> am not certain about this, nor was the patch tested. please review.

You missed several error paths...  and if we're going to clean up the error
handling for this function, we might as well free cpm_pic_host, and do an
of_node_put() before the second of_find_compatible_node(), as well.

> @@ -187,13 +187,15 @@ unsigned int cpm_pic_init(void)
>  		goto end;
>  
>  	if (setup_irq(eirq, &cpm_error_irqaction))
>  		printk(KERN_ERR "Could not allocate CPM error IRQ!");
>  
>  	setbits32(&cpic_reg->cpic_cicr, CICR_IEN);
> -
> +	goto end;
> +io_out:
> +	iounmap(cpic_reg);
>  end:
>  	of_node_put(np);
>  	return sirq;
>  }

Ick.  Maybe better to just duplicate the of_node_put().

-Scott