summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2021-04-11 15:30:52 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2021-04-11 15:30:52 +0000
commita470e81e7c6ef28277fdffb6f1ca51f1d4f5b79c (patch)
treef6dedaa40ce3e365b5a67481db4063abb2628127 /sys/dev/pci/drm
parent4ed7a0fe74801dd21341d8765d8a58ec82e04f92 (diff)
On systems that hide the PCI bridge device corresponding to a PCIe RC port
we may end up passing a NULL pointer to pcie_get_speed_cap(). Handle this by returning PCI_SPEED_UNKNOWN instead of dereferencing a null-pointer. ok jsg@
Diffstat (limited to 'sys/dev/pci/drm')
-rw-r--r--sys/dev/pci/drm/drm_linux.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/dev/pci/drm/drm_linux.c b/sys/dev/pci/drm/drm_linux.c
index 1fc4db15c86..e478bbdeff6 100644
--- a/sys/dev/pci/drm/drm_linux.c
+++ b/sys/dev/pci/drm/drm_linux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_linux.c,v 1.78 2021/02/14 03:42:55 jsg Exp $ */
+/* $OpenBSD: drm_linux.c,v 1.79 2021/04/11 15:30:51 kettenis Exp $ */
/*
* Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org>
* Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
@@ -1760,14 +1760,20 @@ get_dma_buf(struct dma_buf *dmabuf)
enum pci_bus_speed
pcie_get_speed_cap(struct pci_dev *pdev)
{
- pci_chipset_tag_t pc = pdev->pc;
- pcitag_t tag = pdev->tag;
+ pci_chipset_tag_t pc;
+ pcitag_t tag;
int pos ;
pcireg_t xcap, lnkcap = 0, lnkcap2 = 0;
pcireg_t id;
enum pci_bus_speed cap = PCI_SPEED_UNKNOWN;
int bus, device, function;
+ if (pdev == NULL)
+ return PCI_SPEED_UNKNOWN;
+
+ pc = pdev->pc;
+ tag = pdev->tag;
+
if (!pci_get_capability(pc, tag, PCI_CAP_PCIEXPRESS,
&pos, NULL))
return PCI_SPEED_UNKNOWN;