Commit 1aa506e4 authored by Tejun Heo's avatar Tejun Heo Committed by Jeff Garzik

libata: fix ata_host_release() free order

host->ops->host_stop() might access ports.  Free ports after
host_stop.
Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 8ba5e4cb
...@@ -5685,18 +5685,22 @@ static void ata_host_release(struct device *gendev, void *res) ...@@ -5685,18 +5685,22 @@ static void ata_host_release(struct device *gendev, void *res)
for (i = 0; i < host->n_ports; i++) { for (i = 0; i < host->n_ports; i++) {
struct ata_port *ap = host->ports[i]; struct ata_port *ap = host->ports[i];
if (!ap) if (ap && ap->ops->port_stop)
continue;
if (ap->ops->port_stop)
ap->ops->port_stop(ap); ap->ops->port_stop(ap);
scsi_host_put(ap->scsi_host);
} }
if (host->ops->host_stop) if (host->ops->host_stop)
host->ops->host_stop(host); 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); dev_set_drvdata(gendev, NULL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment