Commit 7aaaaa1e authored by Kulikov Vasiliy's avatar Kulikov Vasiliy Committed by David S. Miller

cxgb3: do not use PCI resources before pci_enable_device()

IRQ and resource[] may not have correct values until
after PCI hotplug setup occurs at pci_enable_device() time.

The semantic match that finds this problem is as follows:

// <smpl>
@@
identifier x;
identifier request ~= "pci_request.*|pci_resource.*";
@@

(
* x->irq
|
* x->resource
|
* request(x, ...)
)
 ...
*pci_enable_device(x)
// </smpl>
Signed-off-by: default avatarKulikov Vasiliy <segooon@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3cfc2c42
...@@ -3198,17 +3198,17 @@ static int __devinit init_one(struct pci_dev *pdev, ...@@ -3198,17 +3198,17 @@ static int __devinit init_one(struct pci_dev *pdev,
} }
} }
err = pci_request_regions(pdev, DRV_NAME); err = pci_enable_device(pdev);
if (err) { if (err) {
/* Just info, some other driver may have claimed the device. */ dev_err(&pdev->dev, "cannot enable PCI device\n");
dev_info(&pdev->dev, "cannot obtain PCI resources\n"); goto out;
return err;
} }
err = pci_enable_device(pdev); err = pci_request_regions(pdev, DRV_NAME);
if (err) { if (err) {
dev_err(&pdev->dev, "cannot enable PCI device\n"); /* Just info, some other driver may have claimed the device. */
goto out_release_regions; dev_info(&pdev->dev, "cannot obtain PCI resources\n");
goto out_disable_device;
} }
if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
...@@ -3217,11 +3217,11 @@ static int __devinit init_one(struct pci_dev *pdev, ...@@ -3217,11 +3217,11 @@ static int __devinit init_one(struct pci_dev *pdev,
if (err) { if (err) {
dev_err(&pdev->dev, "unable to obtain 64-bit DMA for " dev_err(&pdev->dev, "unable to obtain 64-bit DMA for "
"coherent allocations\n"); "coherent allocations\n");
goto out_disable_device; goto out_release_regions;
} }
} else if ((err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) != 0) { } else if ((err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) != 0) {
dev_err(&pdev->dev, "no usable DMA configuration\n"); dev_err(&pdev->dev, "no usable DMA configuration\n");
goto out_disable_device; goto out_release_regions;
} }
pci_set_master(pdev); pci_set_master(pdev);
...@@ -3234,7 +3234,7 @@ static int __devinit init_one(struct pci_dev *pdev, ...@@ -3234,7 +3234,7 @@ static int __devinit init_one(struct pci_dev *pdev,
adapter = kzalloc(sizeof(*adapter), GFP_KERNEL); adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
if (!adapter) { if (!adapter) {
err = -ENOMEM; err = -ENOMEM;
goto out_disable_device; goto out_release_regions;
} }
adapter->nofail_skb = adapter->nofail_skb =
...@@ -3370,11 +3370,12 @@ static int __devinit init_one(struct pci_dev *pdev, ...@@ -3370,11 +3370,12 @@ static int __devinit init_one(struct pci_dev *pdev,
out_free_adapter: out_free_adapter:
kfree(adapter); kfree(adapter);
out_disable_device:
pci_disable_device(pdev);
out_release_regions: out_release_regions:
pci_release_regions(pdev); pci_release_regions(pdev);
out_disable_device:
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
out:
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