applicom: fix LEAK, unwind on errors;
Review
Quoted 8 lines · Randy.Dunlap
(quoted diff) +2
-3-#warning "LEAK" - RamIO = ioremap(mem, LEN_RAM_IO * MAX_ISA_BOARD); + maxRamIO = ioremap(mem, LEN_RAM_IO * MAX_ISA_BOARD); - if (!RamIO) + if (!maxRamIO) printk(KERN_INFO "ac.o: Failed to ioremap ISA memory space at 0x%lx\n", mem);
to which Andrew Morton replied:
It seems that this driver is just testing to see if it can ioremap the whole region before going through and mapping each board.
If we want to keep this sanity check then the iounmap should come immediately after the ioremap, or it should just be removed.
Probably the latter: if the individual ioremaps work then they've worked, haven't they?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sure, that's fine by me. David, OK with you?
Here's the updated patch.
--
~Randy
patch_name: applicom_leak2.patchpatch_version: 2003-10-09.19:54:49
author: Randy.Dunlap <[email protected]>
description: remove ioremap() warning and leak;
unwind on errors in init; don't save irq on request_irq() failure;
product: Linuxproduct_versions: 2.6.0-test7
maintainer: David Woodhouse ([email protected])
diffstat: =
drivers/char/applicom.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-)
drivers/char/applicom.c renamed from drivers/char/applicom.c~appleak +5 -7
@@ -214,6 +214,7 @@if (!RamIO) {printk (KERN_INFO "ac.o: Failed to ioremap PCI memory space at 0x%lx\n" , dev->resource[0 ].start); +pci_disable_device (dev);return -EIO ; }
@@ -225,12 +226,14 @@ (unsigned long)RamIO,0))) {printk (KERN_INFO "ac.o: PCI Applicom device doesn't have correct signature.\n" );iounmap (RamIO); +pci_disable_device (dev);continue ; }if (request_irq (dev->irq, &ac_interrupt,SA_SHIRQ ,"Applicom PCI" , &dummy)) {printk (KERN_INFO "Could not allocate IRQ %d for PCI Applicom device.\n" , dev->irq);iounmap (RamIO); +pci_disable_device (dev); apbs[boardno -1 ].RamIO =0 ;continue ; }
@@ -257,12 +260,6 @@/* Now try the specified ISA cards */ -#warning "LEAK" - RamIO =ioremap (mem,LEN_RAM_IO *MAX_ISA_BOARD ); - -if (!RamIO) -printk (KERN_INFO "ac.o: Failed to ioremap ISA memory space at 0x%lx\n" , mem); -for (i =0 ; i <MAX_ISA_BOARD ; i++) { RamIO =ioremap (mem + (LEN_RAM_IO * i),LEN_RAM_IO );
@@ -285,7 +282,8 @@iounmap ((void *) RamIO); apbs[boardno -1 ].RamIO =0 ; } - apbs[boardno -1 ].irq = irq; +else + apbs[boardno -1 ].irq = irq; }else apbs[boardno -1 ].irq =0 ;