diff options
author | Warner Losh <imp@FreeBSD.org> | 2025-02-04 18:29:04 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 2025-02-04 18:29:38 +0000 |
commit | 5c04086a61acbc2c237ca992b85d26c933197009 (patch) | |
tree | 23f63908d51e7c920016fd06472474f36541ca2e | |
parent | 692e5f6ba63e5efe0b3c0a7b9ee6fb255302b000 (diff) |
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
-rw-r--r-- | sys/cam/scsi/scsi_all.c | 8 |
1 files changed, 8 insertions, 0 deletions
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; } } |