mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dominik Brodowski <linux@dominikbrodowski.net>
To: linux-pcmcia@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, amol@verismonetworks.com
Subject: [RFC PATCH 8/11] ioremap balanced with iounmap for drivers/pcmcia
Date: Wed, 25 Oct 2006 22:16:36 -0400	[thread overview]
Message-ID: <20061026021636.GI20473@dominikbrodowski.de> (raw)
In-Reply-To: <20061026021027.GA20473@dominikbrodowski.de>

From: Amol Lad <amol@verismonetworks.com>
Date: Fri, 20 Oct 2006 14:44:18 -0700
Subject: [PATCH] ioremap balanced with iounmap for drivers/pcmcia

ioremap must be balanced by an iounmap and failing to do so can result
in a memory leak.

Signed-off-by: Amol Lad <amol@verismonetworks.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
---
 drivers/pcmcia/at91_cf.c        |    3 ++-
 drivers/pcmcia/au1000_generic.c |   10 ++++++++++
 drivers/pcmcia/m8xx_pcmcia.c    |   12 ++++++++----
 drivers/pcmcia/omap_cf.c        |    3 ++-
 4 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index f8db6e3..3bcb7dc 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -310,9 +310,10 @@ static int __init at91_cf_probe(struct p
 	return 0;
 
 fail2:
-	iounmap((void __iomem *) cf->socket.io_offset);
 	release_mem_region(io->start, io->end + 1 - io->start);
 fail1:
+	if (cf->socket.io_offset)
+		iounmap((void __iomem *) cf->socket.io_offset);
 	if (board->irq_pin)
 		free_irq(board->irq_pin, cf);
 fail0a:
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c
index 5387de6..551bde5 100644
--- a/drivers/pcmcia/au1000_generic.c
+++ b/drivers/pcmcia/au1000_generic.c
@@ -449,6 +449,16 @@ out_err:
 		del_timer_sync(&skt->poll_timer);
 		pcmcia_unregister_socket(&skt->socket);
 		flush_scheduled_work();
+		if (i == 0) {
+			iounmap(skt->virt_io + (u32)mips_io_port_base);
+			skt->virt_io = NULL;
+		}
+#ifndef CONFIG_MIPS_XXS1500
+		else {
+			iounmap(skt->virt_io + (u32)mips_io_port_base);
+			skt->virt_io = NULL;
+		}
+#endif
 		ops->hw_shutdown(skt);
 
 	}
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c
index e070a28..3b72be8 100644
--- a/drivers/pcmcia/m8xx_pcmcia.c
+++ b/drivers/pcmcia/m8xx_pcmcia.c
@@ -427,7 +427,7 @@ static int voltage_set(int slot, int vcc
 			reg |= BCSR1_PCCVCC1;
 			break;
 		default:
-			return 1;
+			goto out_unmap;
 	}
 
 	switch(vpp) {
@@ -438,15 +438,15 @@ static int voltage_set(int slot, int vcc
 			if(vcc == vpp)
 				reg |= BCSR1_PCCVPP1;
 			else
-				return 1;
+				goto out_unmap;
 			break;
 		case 120:
 			if ((vcc == 33) || (vcc == 50))
 				reg |= BCSR1_PCCVPP0;
 			else
-				return 1;
+				goto out_unmap;
 		default:
-			return 1;
+			goto out_unmap;
 	}
 
 	/* first, turn off all power */
@@ -457,6 +457,10 @@ static int voltage_set(int slot, int vcc
 
 	iounmap(bcsr_io);
 	return 0;
+
+out_unmap:
+	iounmap(bcsr_io);
+	return 1;
 }
 
 #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c
index c8e838c..06bf7f4 100644
--- a/drivers/pcmcia/omap_cf.c
+++ b/drivers/pcmcia/omap_cf.c
@@ -309,9 +309,10 @@ static int __devinit omap_cf_probe(struc
 	return 0;
 
 fail2:
-	iounmap((void __iomem *) cf->socket.io_offset);
 	release_mem_region(cf->phys_cf, SZ_8K);
 fail1:
+	if (cf->socket.io_offset)
+		iounmap((void __iomem *) cf->socket.io_offset);
 	free_irq(irq, cf);
 fail0:
 	kfree(cf);
-- 
1.4.3


  parent reply	other threads:[~2006-10-26  2:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-26  2:10 [RFC PATCH 0/11] pcmcia: bugfixes for 2.6.19-rc3 Dominik Brodowski
2006-10-26  2:11 ` [RFC PATCH 1/11] pcmcia: at91_cf update Dominik Brodowski
2006-10-26  2:12 ` [RFC PATCH 2/11] pcmcia: add more IDs to hostap_cs.c Dominik Brodowski
2006-10-26  2:13 ` [RFC PATCH 3/11] pcmcia: update alloc_io_space for conflict checking for multifunction PC card Dominik Brodowski
2006-10-26  2:13 ` [RFC PATCH 4/11] pcmcia/ds: driver layer error checking Dominik Brodowski
2006-10-26  2:14 ` [RFC PATCH 5/11] CONFIG_PM=n slim: drivers/pcmcia/* Dominik Brodowski
2006-10-26  2:14 ` [RFC PATCH 6/11] i82092: wire up errors from pci_register_driver() Dominik Brodowski
2006-10-26  2:15 ` [RFC PATCH 7/11] pcmcia: au1000_generic fix Dominik Brodowski
2006-10-26  2:16 ` Dominik Brodowski [this message]
2006-10-26  2:17 ` [RFC PATCH 9/11] Export soc_common_drv_pcmcia_remove to allow modular PCMCIA Dominik Brodowski
2006-10-26  2:17 ` [RFC PATCH 10/11] PCMCIA: handle sysfs, PCI errors Dominik Brodowski
2006-10-26  2:18 ` [RFC PATCH 11/11] PCMCIA: fix __must_check warnings Dominik Brodowski

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=20061026021636.GI20473@dominikbrodowski.de \
    --to=linux@dominikbrodowski.net \
    --cc=amol@verismonetworks.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pcmcia@lists.infradead.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®