Module Name: src
Committed By: jmcneill
Date: Sun Feb 2 14:45:14 UTC 2020
Modified Files:
src/sys/dev/pci: pciconf.c
Log Message:
Fix null deref for busses with no IO port resources.
To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/pci/pciconf.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/pciconf.c
diff -u src/sys/dev/pci/pciconf.c:1.45 src/sys/dev/pci/pciconf.c:1.46
--- src/sys/dev/pci/pciconf.c:1.45 Mon Jan 20 10:35:42 2020
+++ src/sys/dev/pci/pciconf.c Sun Feb 2 14:45:14 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pciconf.c,v 1.45 2020/01/20 10:35:42 skrll Exp $ */
+/* $NetBSD: pciconf.c,v 1.46 2020/02/02 14:45:14 jmcneill Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pciconf.c,v 1.45 2020/01/20 10:35:42 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pciconf.c,v 1.46 2020/02/02 14:45:14 jmcneill Exp $");
#include "opt_pci.h"
@@ -772,6 +772,12 @@ setup_iowins(pciconf_bus_t *pb)
continue;
pd = pi->dev;
+ if (pb->ioext == NULL) {
+ /* Bus has no IO ranges, disable IO BAR */
+ pi->address = 0;
+ pd->enable &= ~PCI_CONF_ENABLE_IO;
+ goto write_ioaddr;
+ }
pi->address = pci_allocate_range(pb->ioext, pi->size,
pi->align, false);
if (~pi->address == 0) {
@@ -798,6 +804,7 @@ setup_iowins(pciconf_bus_t *pb)
} else {
pd->enable |= PCI_CONF_ENABLE_IO;
}
+write_ioaddr:
if (pci_conf_debug) {
print_tag(pd->pc, pd->tag);
printf("Putting %" PRIu64 " I/O bytes @ %#" PRIx64