diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-05-26 21:54:27 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-05-26 21:54:27 -0400 |
commit | aa8f0dc6c3dbf1cf3ff58f3e945c981be134814d (patch) | |
tree | 3e343cd5493d442d1a26dc7a421422d84698831e /drivers/scsi/libata-core.c | |
parent | bef9c558841604116704e10b3d9ff3dbf4939423 (diff) |
libata: Fix use-after-iounmap
Jens Axboe pointed out that the iounmap() call in libata was occurring
too early, and some drivers (ahci, probably others) were using ioremap'd
memory after it had been unmapped.
The patch should address that problem by way of improving the libata
driver API:
* move ->host_stop() call after all ->port_stop() calls have occurred.
* create default helper function ata_host_stop(), and move iounmap()
call there.
* add ->host_stop_prewalk() hook, use it in sata_qstor.c (hi Mark).
sata_qstor appears to require the host-stop-before-port-stop ordering
that existed prior to applying the attached patch.
Diffstat (limited to 'drivers/scsi/libata-core.c')
-rw-r--r-- | drivers/scsi/libata-core.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index ee9b96da841e..2b41cd3a8ec6 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -3321,6 +3321,13 @@ void ata_port_stop (struct ata_port *ap) | |||
3321 | dma_free_coherent(dev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma); | 3321 | dma_free_coherent(dev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma); |
3322 | } | 3322 | } |
3323 | 3323 | ||
3324 | void ata_host_stop (struct ata_host_set *host_set) | ||
3325 | { | ||
3326 | if (host_set->mmio_base) | ||
3327 | iounmap(host_set->mmio_base); | ||
3328 | } | ||
3329 | |||
3330 | |||
3324 | /** | 3331 | /** |
3325 | * ata_host_remove - Unregister SCSI host structure with upper layers | 3332 | * ata_host_remove - Unregister SCSI host structure with upper layers |
3326 | * @ap: Port to unregister | 3333 | * @ap: Port to unregister |
@@ -3877,10 +3884,6 @@ void ata_pci_remove_one (struct pci_dev *pdev) | |||
3877 | } | 3884 | } |
3878 | 3885 | ||
3879 | free_irq(host_set->irq, host_set); | 3886 | free_irq(host_set->irq, host_set); |
3880 | if (host_set->ops->host_stop) | ||
3881 | host_set->ops->host_stop(host_set); | ||
3882 | if (host_set->mmio_base) | ||
3883 | iounmap(host_set->mmio_base); | ||
3884 | 3887 | ||
3885 | for (i = 0; i < host_set->n_ports; i++) { | 3888 | for (i = 0; i < host_set->n_ports; i++) { |
3886 | ap = host_set->ports[i]; | 3889 | ap = host_set->ports[i]; |
@@ -3899,6 +3902,9 @@ void ata_pci_remove_one (struct pci_dev *pdev) | |||
3899 | scsi_host_put(ap->host); | 3902 | scsi_host_put(ap->host); |
3900 | } | 3903 | } |
3901 | 3904 | ||
3905 | if (host_set->ops->host_stop) | ||
3906 | host_set->ops->host_stop(host_set); | ||
3907 | |||
3902 | kfree(host_set); | 3908 | kfree(host_set); |
3903 | 3909 | ||
3904 | pci_release_regions(pdev); | 3910 | pci_release_regions(pdev); |
@@ -3996,6 +4002,7 @@ EXPORT_SYMBOL_GPL(ata_chk_err); | |||
3996 | EXPORT_SYMBOL_GPL(ata_exec_command); | 4002 | EXPORT_SYMBOL_GPL(ata_exec_command); |
3997 | EXPORT_SYMBOL_GPL(ata_port_start); | 4003 | EXPORT_SYMBOL_GPL(ata_port_start); |
3998 | EXPORT_SYMBOL_GPL(ata_port_stop); | 4004 | EXPORT_SYMBOL_GPL(ata_port_stop); |
4005 | EXPORT_SYMBOL_GPL(ata_host_stop); | ||
3999 | EXPORT_SYMBOL_GPL(ata_interrupt); | 4006 | EXPORT_SYMBOL_GPL(ata_interrupt); |
4000 | EXPORT_SYMBOL_GPL(ata_qc_prep); | 4007 | EXPORT_SYMBOL_GPL(ata_qc_prep); |
4001 | EXPORT_SYMBOL_GPL(ata_bmdma_setup); | 4008 | EXPORT_SYMBOL_GPL(ata_bmdma_setup); |