* inbalanced ioremap/iounmap? in cpm_pic_init(); arch/powerpc/sysdev/commproc.c
@ 2007-11-07 22:01 Roel Kluin
2007-11-08 16:55 ` Scott Wood
0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2007-11-07 22:01 UTC (permalink / raw)
To: linuxppc-dev
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.
--
fix ioremap/iounmap imbalance
Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
---
diff --git a/arch/powerpc/sysdev/commproc.c b/arch/powerpc/sysdev/commproc.c
index f6a6378..7b1dd9c 100644
--- a/arch/powerpc/sysdev/commproc.c
+++ b/arch/powerpc/sysdev/commproc.c
@@ -152,13 +152,13 @@ unsigned int cpm_pic_init(void)
cpic_reg = ioremap(res.start, res.end - res.start + 1);
if (cpic_reg == NULL)
goto end;
sirq = irq_of_parse_and_map(np, 0);
if (sirq == NO_IRQ)
- goto end;
+ goto io_out;
/* Initialize the CPM interrupt controller. */
hwirq = (unsigned int)irq_map[sirq].hwirq;
out_be32(&cpic_reg->cpic_cicr,
(CICR_SCD_SCC4 | CICR_SCC_SCC3 | CICR_SCB_SCC2 | CICR_SCA_SCC1) |
((hwirq/2) << 13) | CICR_HP_MASK);
@@ -167,13 +167,13 @@ unsigned int cpm_pic_init(void)
cpm_pic_host = irq_alloc_host(of_node_get(np), IRQ_HOST_MAP_LINEAR,
64, &cpm_pic_host_ops, 64);
if (cpm_pic_host == NULL) {
printk(KERN_ERR "CPM2 PIC: failed to allocate irq host!\n");
sirq = NO_IRQ;
- goto end;
+ goto io_out;
}
/* Install our own error handler. */
np = of_find_compatible_node(NULL, NULL, "fsl,cpm1");
if (np == NULL)
np = of_find_node_by_type(NULL, "cpm");
@@ -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;
}
void __init cpm_reset(void)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: inbalanced ioremap/iounmap? in cpm_pic_init(); arch/powerpc/sysdev/commproc.c
2007-11-07 22:01 inbalanced ioremap/iounmap? in cpm_pic_init(); arch/powerpc/sysdev/commproc.c Roel Kluin
@ 2007-11-08 16:55 ` Scott Wood
0 siblings, 0 replies; 2+ messages in thread
From: Scott Wood @ 2007-11-08 16:55 UTC (permalink / raw)
To: Roel Kluin; +Cc: linuxppc-dev
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-11-08 16:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-07 22:01 inbalanced ioremap/iounmap? in cpm_pic_init(); arch/powerpc/sysdev/commproc.c Roel Kluin
2007-11-08 16:55 ` Scott Wood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).