Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci make sure PCI_IOC_DRVNAMEONBUS doesn't access NU...



details:   https://anonhg.NetBSD.org/src/rev/c8863be55df3
branches:  trunk
changeset: 985709:c8863be55df3
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Sep 05 03:47:24 2021 +0000

description:
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.

diffstat:

 sys/dev/pci/pci_usrreq.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r d7b39eea3eb3 -r c8863be55df3 sys/dev/pci/pci_usrreq.c
--- a/sys/dev/pci/pci_usrreq.c  Sat Sep 04 21:20:44 2021 +0000
+++ b/sys/dev/pci/pci_usrreq.c  Sun Sep 05 03:47:24 2021 +0000
@@ -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 @@
 
                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 */
                }



Home | Main Index | Thread Index | Old Index