Skip to contentSkip to conversation

libata: fix ata_host_release() free order

PATCH Applied Tejun Heo 2 participants 2 messages Mar 9, 2007 libata

lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 libata: fix ata_host_release() free order

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

---
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(-)
drivers/ata/libata-core.c +10 -6
index cd0ce65..0520950 100644
@@ -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);
 }
 
Signature · 1 line
1.5.0.1
Applied
#1 lore raw
Quoted 10 lines · Tejun Heo

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

---
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