mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Randy.Dunlap" <rddunlap@osdl.org>
To: akpm <akpm@osdl.org>, lkml <linux-kernel@vger.kernel.org>
Cc: dwmw2@infradead.org
Subject: Re: [PATCH] applicom: fix LEAK, unwind on errors;
Date: Thu, 9 Oct 2003 20:04:19 -0700	[thread overview]
Message-ID: <20031009200419.17024c32.rddunlap@osdl.org> (raw)



"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;

             reply	other threads:[~2003-10-10  3:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-10  3:04 Randy.Dunlap [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-10-03 22:46 IA32 - 269 New warnings (gcc 3.2.2) John Cherry
2003-10-03 23:25 ` [PATCH] applicom: fix LEAK, unwind on errors; Randy.Dunlap
2003-10-03 23:55   ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031009200419.17024c32.rddunlap@osdl.org \
    --to=rddunlap@osdl.org \
    --cc=akpm@osdl.org \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®