kern/164313: Fix pci_get_vpd_readonly_method

Chuck Tuffli chuck at
Thu Jan 19 18:30:11 UTC 2012

>Number:         164313
>Category:       kern
>Synopsis:       Fix pci_get_vpd_readonly_method
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 19 18:30:10 UTC 2012
>Originator:     Chuck Tuffli
>Release:        8-stable
FreeBSD 8.2-STABLE FreeBSD 8.2-STABLE #32 r229528M: Thu Jan 19 09:42:27 PST 2012     ctuffli at  amd64

The pci_get_vpd_readonly_method function always returns ENXIO because it is missing a break statement if the keyword is found in the VPD read-only section. Without the break statement, the for loop continues checking the remaining keywords even if it discovers the desired key, and it exits with i == cfg->vpd.vpd_rocnt. This indistinguishable from not finding the desired key.
Issue pci_get_vpd_readonly(dev, "SN", &str) to any device with a valid VPD
Add a break to the "if" statement

Index: sys/dev/pci/pci.c
--- sys/dev/pci/pci.c	(revision 229528)
+++ sys/dev/pci/pci.c	(working copy)
@@ -1076,6 +1076,7 @@
 		if (memcmp(kw, cfg->vpd.vpd_ros[i].keyword,
 		    sizeof(cfg->vpd.vpd_ros[i].keyword)) == 0) {
 			*vptr = cfg->vpd.vpd_ros[i].value;
+			break;
 	if (i != cfg->vpd.vpd_rocnt)


More information about the freebsd-bugs mailing list