lkml.org 
[lkml]   [2003]   [Oct]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] applicom: fix LEAK, unwind on errors;


"Randy.Dunlap" <rddunlap@osdl.org> wrote:
>
> -#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.patch
patch_version: 2003-10-09.19:54:49
author: Randy.Dunlap <rddunlap@osdl.org>
description: remove ioremap() warning and leak;
unwind on errors in init;
don't save irq on request_irq() failure;
product: Linux
product_versions: 2.6.0-test7
maintainer: David Woodhouse (dwmw2@infradead.org)
diffstat: =
drivers/char/applicom.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)


diff -Naur ./drivers/char/applicom.c~appleak ./drivers/char/applicom.c
--- ./drivers/char/applicom.c~appleak 2003-10-08 12:24:50.000000000 -0700
+++ ./drivers/char/applicom.c 2003-10-09 19:52:47.000000000 -0700
@@ -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;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:49    [W:0.025 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site