1
0
xorg-x11-server/p_pci-off-by-one.diff.ia64

65 lines
1.9 KiB
Plaintext

--- hw/xfree86/os-support/bus/linuxPci.c
+++ hw/xfree86/os-support/bus/linuxPci.c
@@ -547,10 +547,10 @@ xf86GetPciDomain(PCITAG Tag)
pPCI = xf86GetPciHostConfigFromTag(Tag);
if (pPCI && (result = PCI_DOM_FROM_BUS(pPCI->busnum)))
- return result + 1;
+ return result;
if (!pPCI || pPCI->fakeDevice)
- return 1; /* Domain 0 is reserved */
+ return 0;
if ((fd = linuxPciOpenFile(pPCI ? pPCI->tag : 0,FALSE)) < 0)
return 0;
@@ -558,7 +558,7 @@ xf86GetPciDomain(PCITAG Tag)
if ((result = ioctl(fd, PCIIOC_CONTROLLER, 0)) < 0)
return 0;
- return result + 1; /* Domain 0 is reserved */
+ return result;
}
static pointer
@@ -629,7 +629,7 @@ linuxMapPci(int ScreenNum, int Flags, PC
return NULL;
}
-#define MAX_DOMAINS 257
+#define MAX_DOMAINS 256
static pointer DomainMmappedIO[MAX_DOMAINS];
static int
@@ -650,11 +650,10 @@ linuxOpenLegacy(PCITAG Tag, char *name)
domain = xf86GetPciDomain(Tag);
bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(Tag));
- /* Domain 0 is reserved -- see xf86GetPciDomain() */
- if ((domain <= 0) || (domain >= MAX_DOMAINS))
+ if ((domain < 0) || (domain >= MAX_DOMAINS))
FatalError("linuxOpenLegacy(): domain out of range\n");
- sprintf(path, PREFIX, domain - 1, bus, name);
+ sprintf(path, PREFIX, domain, bus, name);
fd = open(path, O_RDWR);
if (fd >= 0) {
xfree(path);
@@ -686,7 +685,6 @@ _X_EXPORT pointer
xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag,
ADDRESS Base, unsigned long Size)
{
- int domain = xf86GetPciDomain(Tag);
int fd = -1;
pointer addr;
@@ -734,7 +732,7 @@ xf86MapDomainIO(int ScreenNum, int Flags
int domain = xf86GetPciDomain(Tag);
int fd;
- if ((domain <= 0) || (domain >= MAX_DOMAINS))
+ if ((domain < 0) || (domain >= MAX_DOMAINS))
FatalError("xf86MapDomainIO(): domain out of range\n");
if (DomainMmappedIO[domain])