Commit f01abb36 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by James Bottomley

[SCSI] aic94xx: Free scsi host on error

If an error occurred during initialisation, we would sometimes fail to
call scsi_host_put() and thus end up with a leaked scsi_host.  It was
also possible to miss calling scsi_remove_host().
Signed-off-by: default avatarMatthew Wilcox <matthew@wil.cx>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent a60ebc52
...@@ -583,7 +583,7 @@ static int __devinit asd_pci_probe(struct pci_dev *dev, ...@@ -583,7 +583,7 @@ static int __devinit asd_pci_probe(struct pci_dev *dev,
asd_ha = kzalloc(sizeof(*asd_ha), GFP_KERNEL); asd_ha = kzalloc(sizeof(*asd_ha), GFP_KERNEL);
if (!asd_ha) { if (!asd_ha) {
asd_printk("out of memory\n"); asd_printk("out of memory\n");
goto Err; goto Err_put;
} }
asd_ha->pcidev = dev; asd_ha->pcidev = dev;
asd_ha->sas_ha.dev = &asd_ha->pcidev->dev; asd_ha->sas_ha.dev = &asd_ha->pcidev->dev;
...@@ -600,14 +600,12 @@ static int __devinit asd_pci_probe(struct pci_dev *dev, ...@@ -600,14 +600,12 @@ static int __devinit asd_pci_probe(struct pci_dev *dev,
shost->max_cmd_len = 16; shost->max_cmd_len = 16;
err = scsi_add_host(shost, &dev->dev); err = scsi_add_host(shost, &dev->dev);
if (err) { if (err)
scsi_host_put(shost);
goto Err_free; goto Err_free;
}
err = asd_dev->setup(asd_ha); err = asd_dev->setup(asd_ha);
if (err) if (err)
goto Err_free; goto Err_remove;
err = -ENODEV; err = -ENODEV;
if (!pci_set_dma_mask(dev, DMA_64BIT_MASK) if (!pci_set_dma_mask(dev, DMA_64BIT_MASK)
...@@ -618,14 +616,14 @@ static int __devinit asd_pci_probe(struct pci_dev *dev, ...@@ -618,14 +616,14 @@ static int __devinit asd_pci_probe(struct pci_dev *dev,
; ;
else { else {
asd_printk("no suitable DMA mask for %s\n", pci_name(dev)); asd_printk("no suitable DMA mask for %s\n", pci_name(dev));
goto Err_free; goto Err_remove;
} }
pci_set_drvdata(dev, asd_ha); pci_set_drvdata(dev, asd_ha);
err = asd_map_ha(asd_ha); err = asd_map_ha(asd_ha);
if (err) if (err)
goto Err_free; goto Err_remove;
err = asd_create_ha_caches(asd_ha); err = asd_create_ha_caches(asd_ha);
if (err) if (err)
...@@ -692,9 +690,12 @@ static int __devinit asd_pci_probe(struct pci_dev *dev, ...@@ -692,9 +690,12 @@ static int __devinit asd_pci_probe(struct pci_dev *dev,
asd_destroy_ha_caches(asd_ha); asd_destroy_ha_caches(asd_ha);
Err_unmap: Err_unmap:
asd_unmap_ha(asd_ha); asd_unmap_ha(asd_ha);
Err_remove:
scsi_remove_host(shost);
Err_free: Err_free:
kfree(asd_ha); kfree(asd_ha);
scsi_remove_host(shost); Err_put:
scsi_host_put(shost);
Err: Err:
pci_disable_device(dev); pci_disable_device(dev);
return err; return err;
......
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