Module Name:    src
Committed By:   mrg
Date:           Sun Sep  5 03:47:24 UTC 2021

Modified Files:
        src/sys/dev/pci: pci_usrreq.c

Log Message:
make sure PCI_IOC_DRVNAMEONBUS doesn't access NULL pointers.

hopefully fixes PR#55744.  it's not entirely clear why this does
not affect most systems, as there's usually some PCI devices that
do not have attached drivers, eg:

006:00:0: AMD Family17h/7xh Reserved SPP (non-essential instrumentation, 
subclass 0x00)

on my system i'm testing on.

XXX: pullup-8, pullup-9.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/pci/pci_usrreq.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/pci_usrreq.c
diff -u src/sys/dev/pci/pci_usrreq.c:1.30 src/sys/dev/pci/pci_usrreq.c:1.31
--- src/sys/dev/pci/pci_usrreq.c:1.30	Sat Sep 24 23:12:54 2016
+++ src/sys/dev/pci/pci_usrreq.c	Sun Sep  5 03:47:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_usrreq.c,v 1.30 2016/09/24 23:12:54 mrg Exp $	*/
+/*	$NetBSD: pci_usrreq.c,v 1.31 2021/09/05 03:47:24 mrg Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_usrreq.c,v 1.30 2016/09/24 23:12:54 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_usrreq.c,v 1.31 2021/09/05 03:47:24 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -127,6 +127,8 @@ pciioctl(dev_t dev, u_long cmd, void *da
 
 		for (i = 0; i < pci_cd.cd_ndevs; i++) {
 			sc = device_lookup_private(&pci_cd, i);
+			if (sc == NULL)
+				continue;
 			if (sc->sc_bus == dnameonbus->bus)
 				break;	/* found the right bus */
 		}

Reply via email to