git: 272e4f538467 - main - cam: Fix wiring fence post error
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 13 Jan 2022 22:23:55 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=272e4f538467f41eebf611cf7ce92c5c80afcbff
commit 272e4f538467f41eebf611cf7ce92c5c80afcbff
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-01-13 22:22:13 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-01-13 22:22:56 +0000
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
---
sys/cam/cam_periph.c | 5 +++--
1 file 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;