aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Tabi <timur@freescale.com>2008-08-20 11:29:09 -0400
committerKumar Gala <galak@kernel.crashing.org>2008-08-21 00:58:12 -0400
commit61a4e9e91dd3916ef91aa4899b7271bba0248677 (patch)
treef5efdda2417abec232276f011c4fb422959994e6
parentd27a736c7a62c3451e389aa8e0dfc64dab119b9b (diff)
powerpc: fix memory leaks in QE library
Fix two memory leaks in the Freescale QE library: add a missing kfree() in ucc_fast_init() and ucc_slow_init() if the ioremap() fails, and update ucc_fast_free() and ucc_slow_free() to call iounmap() if necessary. Based on a patch from Tony Breeds <tony@bakeyournoodle.com>. Signed-off-by: Timur Tabi <timur@freescale.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
-rw-r--r--arch/powerpc/sysdev/qe_lib/ucc_fast.c4
-rw-r--r--arch/powerpc/sysdev/qe_lib/ucc_slow.c8
2 files changed, 9 insertions, 3 deletions
diff --git a/arch/powerpc/sysdev/qe_lib/ucc_fast.c b/arch/powerpc/sysdev/qe_lib/ucc_fast.c
index 1aecb075a72e..25fbbfaa837d 100644
--- a/arch/powerpc/sysdev/qe_lib/ucc_fast.c
+++ b/arch/powerpc/sysdev/qe_lib/ucc_fast.c
@@ -208,6 +208,7 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc
208 uccf->uf_regs = ioremap(uf_info->regs, sizeof(struct ucc_fast)); 208 uccf->uf_regs = ioremap(uf_info->regs, sizeof(struct ucc_fast));
209 if (uccf->uf_regs == NULL) { 209 if (uccf->uf_regs == NULL) {
210 printk(KERN_ERR "%s: Cannot map UCC registers\n", __func__); 210 printk(KERN_ERR "%s: Cannot map UCC registers\n", __func__);
211 kfree(uccf);
211 return -ENOMEM; 212 return -ENOMEM;
212 } 213 }
213 214
@@ -355,6 +356,9 @@ void ucc_fast_free(struct ucc_fast_private * uccf)
355 if (uccf->ucc_fast_rx_virtual_fifo_base_offset) 356 if (uccf->ucc_fast_rx_virtual_fifo_base_offset)
356 qe_muram_free(uccf->ucc_fast_rx_virtual_fifo_base_offset); 357 qe_muram_free(uccf->ucc_fast_rx_virtual_fifo_base_offset);
357 358
359 if (uccf->uf_regs)
360 iounmap(uccf->uf_regs);
361
358 kfree(uccf); 362 kfree(uccf);
359} 363}
360EXPORT_SYMBOL(ucc_fast_free); 364EXPORT_SYMBOL(ucc_fast_free);
diff --git a/arch/powerpc/sysdev/qe_lib/ucc_slow.c b/arch/powerpc/sysdev/qe_lib/ucc_slow.c
index a578bc77b9d5..e1d6a1340157 100644
--- a/arch/powerpc/sysdev/qe_lib/ucc_slow.c
+++ b/arch/powerpc/sysdev/qe_lib/ucc_slow.c
@@ -171,6 +171,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
171 uccs->us_regs = ioremap(us_info->regs, sizeof(struct ucc_slow)); 171 uccs->us_regs = ioremap(us_info->regs, sizeof(struct ucc_slow));
172 if (uccs->us_regs == NULL) { 172 if (uccs->us_regs == NULL) {
173 printk(KERN_ERR "%s: Cannot map UCC registers\n", __func__); 173 printk(KERN_ERR "%s: Cannot map UCC registers\n", __func__);
174 kfree(uccs);
174 return -ENOMEM; 175 return -ENOMEM;
175 } 176 }
176 177
@@ -367,10 +368,11 @@ void ucc_slow_free(struct ucc_slow_private * uccs)
367 if (uccs->tx_base_offset) 368 if (uccs->tx_base_offset)
368 qe_muram_free(uccs->tx_base_offset); 369 qe_muram_free(uccs->tx_base_offset);
369 370
370 if (uccs->us_pram) { 371 if (uccs->us_pram)
371 qe_muram_free(uccs->us_pram_offset); 372 qe_muram_free(uccs->us_pram_offset);
372 uccs->us_pram = NULL; 373
373 } 374 if (uccs->us_regs)
375 iounmap(uccs->us_regs);
374 376
375 kfree(uccs); 377 kfree(uccs);
376} 378}