Skip to contentSkip to conversation

sis: do not use PCI resources before pci_enable_device()

PATCH In review Kulikov Vasiliy 1 participant 1 message Aug 3, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 11/11 sis: 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>

---
 drivers/video/sis/sis_main.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)
drivers/video/sis/sis_main.c +5 -8
index 559bf17..47ba64e 100644
@@ -5782,6 +5782,11 @@ sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	ivideo->subsysvendor = pdev->subsystem_vendor;
 	ivideo->subsysdevice = pdev->subsystem_device;
 
+	if (!ivideo->sisvga_enabled && pci_enable_device(pdev)) {
+		framebuffer_release(sis_fb_info);
+		return -EIO;
+	}
+
 #ifndef MODULE
 	if(sisfb_mode_idx = -1) {
 		sisfb_get_vga_mode_from_kernel();
@@ -5923,14 +5928,6 @@ sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	}
 #endif
 
-	if(!ivideo->sisvga_enabled) {
-		if(pci_enable_device(pdev)) {
-			if(ivideo->nbridge) pci_dev_put(ivideo->nbridge);
-			pci_set_drvdata(pdev, NULL);
-			framebuffer_release(sis_fb_info);
-			return -EIO;
-		}
-	}
 
 	ivideo->video_base = pci_resource_start(pdev, 0);
 	ivideo->mmio_base  = pci_resource_start(pdev, 1);
Signature · 1 line
1.7.0.4