Commit 5629236b31239dbaa182cb7eb39aad4d62278f7c

Authored by Kulikov Vasiliy
Committed by Matthew Garrett
1 parent da5cabf80e

x86: intel_ips: 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: Kulikov Vasiliy <segooon@gmail.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Matthew Garrett <mjg@redhat.com>

Showing 1 changed file with 6 additions and 5 deletions Side-by-side Diff

drivers/platform/x86/intel_ips.c
... ... @@ -1432,6 +1432,12 @@
1432 1432  
1433 1433 spin_lock_init(&ips->turbo_status_lock);
1434 1434  
  1435 + ret = pci_enable_device(dev);
  1436 + if (ret) {
  1437 + dev_err(&dev->dev, "can't enable PCI device, aborting\n");
  1438 + goto error_free;
  1439 + }
  1440 +
1435 1441 if (!pci_resource_start(dev, 0)) {
1436 1442 dev_err(&dev->dev, "TBAR not assigned, aborting\n");
1437 1443 ret = -ENXIO;
... ... @@ -1444,11 +1450,6 @@
1444 1450 goto error_free;
1445 1451 }
1446 1452  
1447   - ret = pci_enable_device(dev);
1448   - if (ret) {
1449   - dev_err(&dev->dev, "can't enable PCI device, aborting\n");
1450   - goto error_free;
1451   - }
1452 1453  
1453 1454 ips->regmap = ioremap(pci_resource_start(dev, 0),
1454 1455 pci_resource_len(dev, 0));