[PATCH kernel 3.0-rc1] smc91c92_cs: set smc->base to NULL before iounmap
From: Ken Kawasaki <hidden>
Date: 2011-06-04 23:28:53
smc91c92_cs:
set smc->base to NULL before iounmap
to avoid writing to smc->base in smc_interrupt.
Signed-off-by: Ken Kawasaki <redacted>
---
--- linux-3.0-rc1/drivers/net/pcmcia/smc91c92_cs.c.orig 2011-06-04 19:38:07.000000000 +0900
+++ linux-3.0-rc1/drivers/net/pcmcia/smc91c92_cs.c 2011-06-05 07:59:51.000000000 +0900@@ -315,6 +315,7 @@ static int smc91c92_probe(struct pcmcia_ smc = netdev_priv(dev); smc->p_dev = link; link->priv = dev; + smc->base = NULL; spin_lock_init(&smc->lock);
@@ -954,11 +955,17 @@ config_failed: static void smc91c92_release(struct pcmcia_device *link) { + struct net_device *dev = link->priv; + struct smc_private *smc = netdev_priv(dev); + dev_dbg(&link->dev, "smc91c92_release\n"); - if (link->resource[2]->end) { - struct net_device *dev = link->priv; - struct smc_private *smc = netdev_priv(dev); - iounmap(smc->base); + + if (smc->base != NULL) { + u_char __iomem *tmp; + + tmp = smc->base; + smc->base = NULL; /* set NULL before iounmap */ + iounmap(tmp); } pcmcia_disable_device(link); }
@@ -1444,7 +1451,7 @@ irq_done: mask_bits(0x00ff, ioaddr-0x10+OSITECH_RESET_ISR); set_bits(0x0300, ioaddr-0x10+OSITECH_RESET_ISR); } - if (smc->manfid == MANFID_MOTOROLA) { + if ((smc->base != NULL) && (smc->manfid == MANFID_MOTOROLA)) { u_char cor; cor = readb(smc->base + MOT_UART + CISREG_COR); writeb(cor & ~COR_IREQ_ENA, smc->base + MOT_UART + CISREG_COR);