Commit 1c85382e authored by Lino Sanfilippo's avatar Lino Sanfilippo Committed by David S. Miller

sky2: fix cleanup sequence in probe() function

The cleanup sequence in sky2_probe() that is called in case of an error is
mixed up in different places:

- pci_disable_device() is not called in each case the device has been enabled
before

- same for pci_disable_msi(): test_msi() may return with an error != EOPNOTSUPP
(due to failure of request_irq()). In that case msi is not disabled

- also failure of register_netdev() does not disable msi

This patch fixes the concerning parts.
Signed-off-by: default avatarLino Sanfilippo <LinoSanfilippo@gmx.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cb64edb6
...@@ -4919,13 +4919,13 @@ static int __devinit sky2_probe(struct pci_dev *pdev, ...@@ -4919,13 +4919,13 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
err = pci_read_config_dword(pdev, PCI_DEV_REG2, &reg); err = pci_read_config_dword(pdev, PCI_DEV_REG2, &reg);
if (err) { if (err) {
dev_err(&pdev->dev, "PCI read config failed\n"); dev_err(&pdev->dev, "PCI read config failed\n");
goto err_out; goto err_out_disable;
} }
if (~reg == 0) { if (~reg == 0) {
dev_err(&pdev->dev, "PCI configuration read error\n"); dev_err(&pdev->dev, "PCI configuration read error\n");
err = -EIO; err = -EIO;
goto err_out; goto err_out_disable;
} }
err = pci_request_regions(pdev, DRV_NAME); err = pci_request_regions(pdev, DRV_NAME);
...@@ -5012,10 +5012,11 @@ static int __devinit sky2_probe(struct pci_dev *pdev, ...@@ -5012,10 +5012,11 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
if (!disable_msi && pci_enable_msi(pdev) == 0) { if (!disable_msi && pci_enable_msi(pdev) == 0) {
err = sky2_test_msi(hw); err = sky2_test_msi(hw);
if (err == -EOPNOTSUPP) if (err) {
pci_disable_msi(pdev); pci_disable_msi(pdev);
else if (err) if (err != -EOPNOTSUPP)
goto err_out_free_netdev; goto err_out_free_netdev;
}
} }
err = register_netdev(dev); err = register_netdev(dev);
...@@ -5063,10 +5064,10 @@ err_out_unregister_dev1: ...@@ -5063,10 +5064,10 @@ err_out_unregister_dev1:
err_out_free_dev1: err_out_free_dev1:
free_netdev(dev1); free_netdev(dev1);
err_out_unregister: err_out_unregister:
if (hw->flags & SKY2_HW_USE_MSI)
pci_disable_msi(pdev);
unregister_netdev(dev); unregister_netdev(dev);
err_out_free_netdev: err_out_free_netdev:
if (hw->flags & SKY2_HW_USE_MSI)
pci_disable_msi(pdev);
free_netdev(dev); free_netdev(dev);
err_out_free_pci: err_out_free_pci:
pci_free_consistent(pdev, hw->st_size * sizeof(struct sky2_status_le), pci_free_consistent(pdev, hw->st_size * sizeof(struct sky2_status_le),
......
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