All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: w.sang@pengutronix.de, linux-ide@vger.kernel.org,
	linux-pcmcia@lists.infradead.org, linux@dominikbrodowski.net
Subject: Re: [PATCH] ide/ide-cs: fix order of releasing resources
Date: Thu, 14 Jan 2010 16:50:17 +0100	[thread overview]
Message-ID: <201001141650.17348.bzolnier@gmail.com> (raw)
In-Reply-To: <20100114.015938.224705378.davem@davemloft.net>

On Thursday 14 January 2010 10:59:38 am David Miller wrote:
> 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!

Port resources should not be freed before ide_host_remove() call in
ide_release() returns as port and/or devices may still be in use.

FWIW the following modified version of the patch is now in my atang tree:

From: Wolfram Sang <w.sang@pengutronix.de>
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 <w.sang@pengutronix.de>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-cs.c |   23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

Index: b/drivers/ide/ide-cs.c
===================================================================
--- a/drivers/ide/ide-cs.c
+++ b/drivers/ide/ide-cs.c
@@ -131,19 +131,11 @@ static int ide_probe(struct pcmcia_devic
 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;
 
     DEBUG(0, "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 */
 
@@ -365,12 +357,19 @@ static void ide_release(struct pcmcia_de
 
     DEBUG(0, "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 */
+    if (info->ndev) {
+	ide_hwif_t *hwif = host->ports[0];
+	unsigned long data_addr, ctl_addr;
+
+	data_addr = hwif->io_ports.data_addr;
+	ctl_addr = hwif->io_ports.ctl_addr;
+
 	ide_host_remove(host);
+	info->ndev = 0;
 
-    info->ndev = 0;
+	release_region(ctl_addr, 1);
+	release_region(data_addr, 8);
+    }
 
     pcmcia_disable_device(link);
 } /* ide_release */

  reply	other threads:[~2010-01-14 17:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-12 19:34 [PATCH] ide/ide-cs: fix order of releasing resources Wolfram Sang
2010-01-14  9:59 ` David Miller
2010-01-14 15:50   ` Bartlomiej Zolnierkiewicz [this message]
2010-01-15  9:31     ` David Miller
2010-01-15  9:43       ` Wolfram Sang
2010-01-16 18:51       ` Wolfram Sang
2010-01-18  2:59         ` David Miller
2010-01-14 10:38 ` 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=201001141650.17348.bzolnier@gmail.com \
    --to=bzolnier@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-pcmcia@lists.infradead.org \
    --cc=linux@dominikbrodowski.net \
    --cc=w.sang@pengutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.