summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2010-02-28 21:37:55 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2010-02-28 21:37:55 +0000
commitf93640471000b8e53078d9db924d309145496368 (patch)
tree35d18de462556ca1191b6c8cf8ba820db8c69785 /sys
parentc7ebfc8570d09b148f276b841f5990e56da5c86e (diff)
In pci_mapreg_map(), do not blindly dereference a possible NULL pointer
upon stumbling on a BAR which value is zero. Found the hard way by kurt@, ok kettenis@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/pci_map.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/sys/dev/pci/pci_map.c b/sys/dev/pci/pci_map.c
index 3a040617f3b..bfddaa35294 100644
--- a/sys/dev/pci/pci_map.c
+++ b/sys/dev/pci/pci_map.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_map.c,v 1.27 2009/10/06 21:35:43 kettenis Exp $ */
+/* $OpenBSD: pci_map.c,v 1.28 2010/02/28 21:37:54 miod Exp $ */
/* $NetBSD: pci_map.c,v 1.7 2000/05/10 16:58:42 thorpej Exp $ */
/*-
@@ -342,12 +342,16 @@ pci_mapreg_map(struct pci_attach_args *pa, int reg, pcireg_t type, int busflags,
if (PCI_MAPREG_TYPE(type) == PCI_MAPREG_TYPE_IO) {
ex = pa->pa_ioex;
- start = max(PCI_IO_START, ex->ex_start);
- end = min(PCI_IO_END, ex->ex_end);
+ if (ex != NULL) {
+ start = max(PCI_IO_START, ex->ex_start);
+ end = min(PCI_IO_END, ex->ex_end);
+ }
} else {
ex = pa->pa_memex;
- start = max(PCI_MEM_START, ex->ex_start);
- end = min(PCI_MEM_END, ex->ex_end);
+ if (ex != NULL) {
+ start = max(PCI_MEM_START, ex->ex_start);
+ end = min(PCI_MEM_END, ex->ex_end);
+ }
}
if (ex == NULL || extent_alloc_subregion(ex, start, end,