On Fri, Mar 05, 2021 at 09:22:28AM -0700, Theo de Raadt wrote: > Fix dump() to convert subclass == NULL into something else, or maybe the > fix should be in pci_subclass() itself.
My initial mistake was to use zero in an empty list. This leads to one element in the list, which causes wrong list handling in the followup code path. So, the following diff remove the zero from the list. Also, add a check for ps->name is NULL, to prevent dump() to print (null). And fix a useless line break while here. OK? Thanks, Jan Index: pcidump.c =================================================================== RCS file: /cvs/src/usr.sbin/pcidump/pcidump.c,v retrieving revision 1.62 diff -u -p -r1.62 pcidump.c --- pcidump.c 5 Mar 2021 12:57:20 -0000 1.62 +++ pcidump.c 5 Mar 2021 17:05:40 -0000 @@ -1296,8 +1296,8 @@ static const struct pci_subclass pci_sub { PCI_SUBCLASS_DASP_MISC, "Miscellaneous" }, }; -static const struct pci_subclass pci_subclass_accelerator[] = {0}; -static const struct pci_subclass pci_subclass_instrumentation[] = {0}; +static const struct pci_subclass pci_subclass_accelerator[] = {}; +static const struct pci_subclass pci_subclass_instrumentation[] = {}; #define CLASS(_c, _n, _s) { \ .class = _c, \ @@ -1389,7 +1389,6 @@ pci_class_name(pci_class_t class) return (pc->name); } - static const char * pci_subclass_name(pci_class_t class, pci_subclass_t subclass) { @@ -1401,7 +1400,7 @@ pci_subclass_name(pci_class_t class, pci return ("(unknown)"); ps = pci_subclass(pc, subclass); - if (ps == NULL) + if (ps == NULL || ps->name == NULL) return ("(unknown)"); return (ps->name);