libata: fix ata_host_release() free order
host->ops->host_stop() might access ports. Free ports after host_stop. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
This commit is contained in:
parent
8ba5e4cbe4
commit
1aa506e437
1 changed files with 10 additions and 6 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue