提交 7a0c2029 编写于 作者: K Kulikov Vasiliy 提交者: David S. Miller

cxgb4vf: 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: NKulikov Vasiliy <segooon@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 7aaaaa1e
...@@ -2462,23 +2462,24 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev, ...@@ -2462,23 +2462,24 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev,
version_printed = 1; version_printed = 1;
} }
/* /*
* Reserve PCI resources for the device. If we can't get them some * Initialize generic PCI device state.
* other driver may have already claimed the device ...
*/ */
err = pci_request_regions(pdev, KBUILD_MODNAME); err = pci_enable_device(pdev);
if (err) { if (err) {
dev_err(&pdev->dev, "cannot obtain PCI resources\n"); dev_err(&pdev->dev, "cannot enable PCI device\n");
return err; return err;
} }
/* /*
* Initialize generic PCI device state. * Reserve PCI resources for the device. If we can't get them some
* other driver may have already claimed the device ...
*/ */
err = pci_enable_device(pdev); err = pci_request_regions(pdev, KBUILD_MODNAME);
if (err) { if (err) {
dev_err(&pdev->dev, "cannot enable PCI device\n"); dev_err(&pdev->dev, "cannot obtain PCI resources\n");
goto err_release_regions; goto err_disable_device;
} }
/* /*
...@@ -2491,14 +2492,14 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev, ...@@ -2491,14 +2492,14 @@ static int __devinit cxgb4vf_pci_probe(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 err_disable_device; goto err_release_regions;
} }
pci_using_dac = 1; pci_using_dac = 1;
} else { } else {
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
if (err != 0) { if (err != 0) {
dev_err(&pdev->dev, "no usable DMA configuration\n"); dev_err(&pdev->dev, "no usable DMA configuration\n");
goto err_disable_device; goto err_release_regions;
} }
pci_using_dac = 0; pci_using_dac = 0;
} }
...@@ -2514,7 +2515,7 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev, ...@@ -2514,7 +2515,7 @@ static int __devinit cxgb4vf_pci_probe(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 err_disable_device; goto err_release_regions;
} }
pci_set_drvdata(pdev, adapter); pci_set_drvdata(pdev, adapter);
adapter->pdev = pdev; adapter->pdev = pdev;
...@@ -2750,13 +2751,13 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev, ...@@ -2750,13 +2751,13 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev,
kfree(adapter); kfree(adapter);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
err_disable_device:
pci_disable_device(pdev);
pci_clear_master(pdev);
err_release_regions: err_release_regions:
pci_release_regions(pdev); pci_release_regions(pdev);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
pci_clear_master(pdev);
err_disable_device:
pci_disable_device(pdev);
err_out: err_out:
return err; return err;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册