From d4ae5415c6f2dd8f14e027c24f09d708f11a8d60 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 15 Jan 2010 01:33:08 -0800 Subject: [PATCH] ide/ide-cs: fix order of releasing resources ide_detach() called first ide_release() and then release_region(). This produced the following warnings: Trying to free nonexistent resource <000000000000c10e-000000000000c10e> Trying to free nonexistent resource <000000000000c100-000000000000c107> This is true, because the callchain inside ide_release() is: ide_release -> pcmcia_disable_device -> pcmcia_release_io So, the whole io-block is already gone for release_region(). To fix this, just swap the order of releasing (and remove the now obsolete shadowing). bzolnier: - release resources in ide_release() to fix ordering of events - remove stale FIXME note while at it Signed-off-by: Wolfram Sang Signed-off-by: Bartlomiej Zolnierkiewicz Signed-off-by: David S. Miller --- drivers/ide/ide-cs.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/ide/ide-cs.c b/drivers/ide/ide-cs.c index dd6396384c25..ab87e4f7cec9 100644 --- a/drivers/ide/ide-cs.c +++ b/drivers/ide/ide-cs.c @@ -121,19 +121,11 @@ static int ide_probe(struct pcmcia_device *link) static void ide_detach(struct pcmcia_device *link) { ide_info_t *info = link->priv; - ide_hwif_t *hwif = info->host->ports[0]; - unsigned long data_addr, ctl_addr; dev_dbg(&link->dev, "ide_detach(0x%p)\n", link); - data_addr = hwif->io_ports.data_addr; - ctl_addr = hwif->io_ports.ctl_addr; - ide_release(link); - release_region(ctl_addr, 1); - release_region(data_addr, 8); - kfree(info); } /* ide_detach */ @@ -354,12 +346,19 @@ static void ide_release(struct pcmcia_device *link) dev_dbg(&link->dev, "ide_release(0x%p)\n", link); - if (info->ndev) - /* FIXME: if this fails we need to queue the cleanup somehow - -- need to investigate the required PCMCIA magic */ - ide_host_remove(host); + if (info->ndev) { + ide_hwif_t *hwif = host->ports[0]; + unsigned long data_addr, ctl_addr; - info->ndev = 0; + data_addr = hwif->io_ports.data_addr; + ctl_addr = hwif->io_ports.ctl_addr; + + ide_host_remove(host); + info->ndev = 0; + + release_region(ctl_addr, 1); + release_region(data_addr, 8); + } pcmcia_disable_device(link); } /* ide_release */