aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2022-01-13 22:22:13 +0000
committerWarner Losh <imp@FreeBSD.org>2022-01-13 22:22:56 +0000
commit272e4f538467f41eebf611cf7ce92c5c80afcbff (patch)
tree47e3c38806ebf386157b17c1350bfab9e1eb5eca
parent82bfeeff10da860b1ed9f03a01f3282b42b991be (diff)
downloadsrc-272e4f538467f41eebf611cf7ce92c5c80afcbff.tar.gz
src-272e4f538467f41eebf611cf7ce92c5c80afcbff.zip
cam: Fix wiring fence post error
If the last matching device entry partially matched in camperiphunit, but then hit a continue case, we'd mistakenly think we had a match on that entry. This lead to a number of problems downstream (usually a belief that we had a duplicate wiring hint because unit = 0 is the default). Fix this by using a for loop that does the assignment before the loop termination test. Sponsored by: Netflix Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D33873
-rw-r--r--sys/cam/cam_periph.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c
index 1203ac2d9b21..869691f59a72 100644
--- a/sys/cam/cam_periph.c
+++ b/sys/cam/cam_periph.c
@@ -611,8 +611,9 @@ camperiphunit(struct periph_driver *p_drv, path_id_t pathid,
unit = 0;
i = 0;
dname = periph_name;
- while (resource_find_dev(&i, dname, &dunit, NULL, NULL) == 0) {
- wired = false;
+
+ for (wired = false; resource_find_dev(&i, dname, &dunit, NULL, NULL) == 0;
+ wired = false) {
if (resource_string_value(dname, dunit, "at", &strval) == 0) {
if (strcmp(strval, pathbuf) != 0)
continue;