git: 5c04086a61ac - main - cam: Fix off by one error in ASC/ASCQ lookup
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 04 Feb 2025 18:31:52 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=5c04086a61acbc2c237ca992b85d26c933197009
commit 5c04086a61acbc2c237ca992b85d26c933197009
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2025-02-04 18:29:04 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-02-04 18:29:38 +0000
cam: Fix off by one error in ASC/ASCQ lookup
To implement ranges of ASC/ASCQ codes, we set SS_RANGE on an entry with
the entry being the end (highest) of the range (with the prior entry
being the start). When looking up a ASC/ASCQ code, however, we return
the second entry, which just has the range info. Instead, return the
prior entry in these cases so we can print the ASC/ASCQ code string
correctly.
Sponsored by: Netflix
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D48685
---
sys/cam/scsi/scsi_all.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/sys/cam/scsi/scsi_all.c b/sys/cam/scsi/scsi_all.c
index 6fbcb1fd80fe..13a376ebb6e3 100644
--- a/sys/cam/scsi/scsi_all.c
+++ b/sys/cam/scsi/scsi_all.c
@@ -3419,7 +3419,15 @@ fetchtableentries(int sense_key, int asc, int ascq,
ascentrycomp);
if (found_entry) {
+ /*
+ * If we get to the SSQ_RANGE entry, we're one too
+ * far. The prior entry is the interesting one, since it
+ * contains the string to print, etc. Only the top end
+ * range is interesting in this entry.
+ */
*asc_entry = (struct asc_table_entry *)found_entry;
+ if (((*asc_entry)->action & SSQ_RANGE) != 0)
+ (*asc_entry)--;
break;
}
}