]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
libata: fix ata_host_release() free order
authorTejun Heo <htejun@gmail.com>
Fri, 9 Mar 2007 10:36:12 +0000 (19:36 +0900)
committerJeff Garzik <jeff@garzik.org>
Fri, 9 Mar 2007 13:41:16 +0000 (08:41 -0500)
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>
drivers/ata/libata-core.c

index f6408ca82062f9375228158be9e9b23aa9cd0846..3c1f8830ac8bf7dedef3d44b049beefcf695e811 100644 (file)
@@ -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);
 }