From: Tejun Heo Date: Fri, 9 Mar 2007 10:36:12 +0000 (+0900) Subject: libata: fix ata_host_release() free order X-Git-Tag: Ubuntu-5.2.0-15.16~45976 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=1aa506e437a94d520f852d39d5d6a6e7f2e01901;p=mirror_ubuntu-eoan-kernel.git libata: fix ata_host_release() free order host->ops->host_stop() might access ports. Free ports after host_stop. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index f6408ca82062..3c1f8830ac8b 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -5685,18 +5685,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); }