diff options
author | Matthieu Herrb <matthieu@herrb.eu> | 2024-05-05 20:50:08 +0200 |
---|---|---|
committer | Matthieu Herrb <matthieu@herrb.eu> | 2024-05-05 20:50:08 +0200 |
commit | 43056800dd6274d854df718e8d86730e8726a8ac (patch) | |
tree | d36ae372b85ecd4e2637a643d7229a16f65cb03d | |
parent | 3cb4d40f88479bbcc994543327a0505ce8b54ee0 (diff) |
Fix running totally unprivileged with startx(1).
-rw-r--r-- | src/openbsd_pci.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/openbsd_pci.c b/src/openbsd_pci.c index 9e6717d..b0b3c5f 100644 --- a/src/openbsd_pci.c +++ b/src/openbsd_pci.c @@ -737,7 +737,7 @@ pci_system_openbsd_init_dev_mem(int fd) int pci_device_vgaarb_init(void) { - struct pci_device *dev = pci_sys->vga_target; + struct pci_device *dev; struct pci_device_iterator *iter; struct pci_id_match vga_match = { PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, @@ -746,12 +746,16 @@ pci_device_vgaarb_init(void) }; struct pci_vga pv; int err; - #ifdef CPU_ALLOWAPERTURE int mib[2]; int allowaperture; size_t len; +#endif + + if (pci_sys == NULL) + return ENXIO; +#ifdef CPU_ALLOWAPERTURE mib[0] = CTL_MACHDEP; mib[1] = CPU_ALLOWAPERTURE; len = sizeof(allowaperture); @@ -762,7 +766,7 @@ pci_device_vgaarb_init(void) return 0; } #endif - + dev = pci_sys->vga_target; pv.pv_sel.pc_bus = 0; pv.pv_sel.pc_dev = 0; pv.pv_sel.pc_func = 0; |