-
Notifications
You must be signed in to change notification settings - Fork 0
/
libpciaccess-no-root.patch
60 lines (56 loc) · 1.92 KB
/
libpciaccess-no-root.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
diff --git a/src/common_bridge.c b/src/common_bridge.c
index 4a067b9..93ccc41 100644
--- a/src/common_bridge.c
+++ b/src/common_bridge.c
@@ -212,8 +212,9 @@ pci_device_get_bridge_info( struct pci_device * dev )
{
struct pci_device_private * priv = (struct pci_device_private *) dev;
- if (priv->bridge.pci == NULL) {
- read_bridge_info(priv);
+ if (priv->bridge.pci == NULL || priv->bridge.pcmcia == NULL) {
+ if (read_bridge_info(priv))
+ return NULL;
}
return ((priv->header_type & 0x7f) == 1) ? priv->bridge.pci : NULL;
@@ -273,6 +274,10 @@ pci_device_get_bridge_buses(struct pci_device * dev, int *primary_bus,
return ENODEV;
}
+ if (!priv->bridge.pci) {
+ return ENODEV;
+ }
+
switch ((dev->device_class >> 8) & 0x0ff) {
case 0x00:
/* What to do for host bridges? I'm pretty sure this isn't right.
diff --git a/src/linux_sysfs.c b/src/linux_sysfs.c
index 9566d40..3f069fb 100644
--- a/src/linux_sysfs.c
+++ b/src/linux_sysfs.c
@@ -373,8 +373,8 @@ pci_device_linux_sysfs_read_rom( struct pci_device * dev, void * buffer )
dev->bus,
dev->dev,
dev->func );
-
- fd = open( name, O_RDWR | O_CLOEXEC);
+
+ fd = open( name, O_RDONLY | O_CLOEXEC);
if ( fd == -1 ) {
#ifdef LINUX_ROM
/* If reading the ROM using sysfs fails, fall back to the old
@@ -621,7 +621,7 @@ pci_device_linux_sysfs_map_range(struct pci_device *dev,
/* For WC mappings, try sysfs resourceN_wc file first */
if ((map->flags & PCI_DEV_MAP_FLAG_WRITE_COMBINE) &&
!pci_device_linux_sysfs_map_range_wc(dev, map))
- return 0;
+ goto mmap_done;
snprintf(name, 255, "%s/%04x:%02x:%02x.%1u/resource%u",
SYS_BUS_PCI,
@@ -643,7 +643,7 @@ pci_device_linux_sysfs_map_range(struct pci_device *dev,
close(fd);
return errno;
}
-
+mmap_done:
#ifdef HAVE_MTRR
if ((map->flags & PCI_DEV_MAP_FLAG_CACHABLE) != 0) {
sentry.type = MTRR_TYPE_WRBACK;