Patchwork ide/ide-cs: fix order of releasing resources

login
register
mail settings
Submitter Wolfram Sang
Date Jan. 12, 2010, 7:34 p.m.
Message ID <1263324894-28117-1-git-send-email-w.sang@pengutronix.de>
Download mbox | patch
Permalink /patch/42747/
State Accepted
Delegated to: David Miller
Headers show

Comments

Wolfram Sang - Jan. 12, 2010, 7:34 p.m.
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).

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
---
 drivers/ide/ide-cs.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
David Miller - Jan. 14, 2010, 9:59 a.m.
From: Wolfram Sang <w.sang@pengutronix.de>
Date: Tue, 12 Jan 2010 20:34:54 +0100

> 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).
> 
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>

Applied, thanks a lot!
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dominik Brodowski - Jan. 14, 2010, 10:38 a.m.
On Tue, Jan 12, 2010 at 08:34:54PM +0100, Wolfram Sang wrote:
> 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).
> 
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> Cc: "David S. Miller" <davem@davemloft.net>
Acked-by: Dominik Brodowski <linux@dominikbrodowski.net>

Best,
	Dominik
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/ide/ide-cs.c b/drivers/ide/ide-cs.c
index dd63963..43ed330 100644
--- a/drivers/ide/ide-cs.c
+++ b/drivers/ide/ide-cs.c
@@ -122,18 +122,14 @@  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;
+    release_region(hwif->io_ports.ctl_addr, 1);
+    release_region(hwif->io_ports.data_addr, 8);
 
     ide_release(link);
 
-    release_region(ctl_addr, 1);
-    release_region(data_addr, 8);
-
     kfree(info);
 } /* ide_detach */