Skip to contentSkip to conversation

i386/x86-64: Return defined error value for bad PCI config space accesses

PATCH Jeff Garzik 2 participants 2 messages Apr 9, 2006 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 29 lines · Linux Kernel Mailing List
(quoted diff) +3 -1
-	if (!value || (bus > 255) || (devfn > 255) || (reg > 255))
+	if (!value || (bus > 255) || (devfn > 255) || (reg > 255)) {
+		*value = -1;
 		return -EINVAL;
+	}
 
 	spin_lock_irqsave(&pci_config_lock, flags);
arch/i386/pci/mmconfig.c +3 -1
index 2002c74..f77d7f8 100644
@@ -80,8 +80,10 @@ static int pci_mmcfg_read(unsigned int s
 	unsigned long flags;
 	u32 base;
 
-	if (!value || (bus > 255) || (devfn > 255) || (reg > 4095))
+	if (!value || (bus > 255) || (devfn > 255) || (reg > 4095)) {
+		*value = -1;
 		return -EINVAL;
+	}
 
 	base = get_base_addr(seg, bus, devfn);
 	if (!base)
arch/x86_64/pci/mmconfig.c +0 -0
index d4e25f3..b493ed9 100644

arch/x86_64/pci/mmconfig.c static int pci_mmcfg_read(unsigned int s · line 79

Quoted 6 lines
arch/x86_64/pci/mmconfig.c +2 -1
@@ -75,8 +75,10 @@ static int pci_mmcfg_read(unsigned int s
 	char __iomem *addr;
 
 	/* Why do we have this when nobody checks it. How about a BUG()!? -AK */
-	if (unlikely(!value || (bus > 255) || (devfn > 255) || (reg > 4095)))
+	if (unlikely(!value || (bus > 255) || (devfn > 255) || (reg > 4095))) {
+		*value = -1;

As the code check indicates, value might be NULL.

Please fix.

Jeff

#2 lore raw
Quoted 3 lines · Jeff Garzik

As the code check indicates, value might be NULL.

Please fix.

It should never be NULL. If anything that's a BUG_ON, but crashing on it is ok too.

But I'll change it to a BUG_ON in the next patch thanks.

-Andi