linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libata: fix ata_host_release() free order
@ 2007-03-09 10:36 Tejun Heo
  2007-03-09 12:51 ` Jeff Garzik
  0 siblings, 1 reply; 2+ messages in thread
From: Tejun Heo @ 2007-03-09 10:36 UTC (permalink / raw)
  To: Jeff Garzik, linux-ide

host->ops->host_stop() might access ports.  Free ports after
host_stop.

Signed-off-by: Tejun Heo <htejun@gmail.com>
---
This one fixes oops on pdc_adma unloading and needs to go to
libata-dev#upstream-fixes.

 drivers/ata/libata-core.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index cd0ce65..0520950 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5668,18 +5668,22 @@ static void ata_host_release(struct device *gendev, void *res)
 	for (i = 0; i < host->n_ports; i++) {
 		struct ata_port *ap = host->ports[i];
 
-		if (!ap)
-			continue;
-
-		if (ap->ops->port_stop)
+		if (ap && ap->ops->port_stop)
 			ap->ops->port_stop(ap);
-
-		scsi_host_put(ap->scsi_host);
 	}
 
 	if (host->ops->host_stop)
 		host->ops->host_stop(host);
 
+	for (i = 0; i < host->n_ports; i++) {
+		struct ata_port *ap = host->ports[i];
+
+		if (ap)
+			scsi_host_put(ap->scsi_host);
+
+		host->ports[i] = NULL;
+	}
+
 	dev_set_drvdata(gendev, NULL);
 }
 
-- 
1.5.0.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] libata: fix ata_host_release() free order
  2007-03-09 10:36 [PATCH] libata: fix ata_host_release() free order Tejun Heo
@ 2007-03-09 12:51 ` Jeff Garzik
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2007-03-09 12:51 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide

Tejun Heo wrote:
> host->ops->host_stop() might access ports.  Free ports after
> host_stop.
> 
> Signed-off-by: Tejun Heo <htejun@gmail.com>
> ---
> This one fixes oops on pdc_adma unloading and needs to go to
> libata-dev#upstream-fixes.
> 
>  drivers/ata/libata-core.c |   16 ++++++++++------
>  1 files changed, 10 insertions(+), 6 deletions(-)

applied to #upstream-fixes



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-09 12:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-09 10:36 [PATCH] libata: fix ata_host_release() free order Tejun Heo
2007-03-09 12:51 ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).