* [PATCH v2] scsi: fix upper bounds check of sense key in scsi_sense_key_string()
@ 2016-08-12 22:20 Tyrel Datwyler
2016-08-16 4:51 ` Martin K. Petersen
0 siblings, 1 reply; 2+ messages in thread
From: Tyrel Datwyler @ 2016-08-12 22:20 UTC (permalink / raw)
To: james.bottomley
Cc: martin.petersen, linux-scsi, bart.vanassche, Tyrel Datwyler
Commit 655ee63cf371 added a "Completed" sense string with key 0xF to
snstext[], but failed to updated the upper bounds check of the sense key in
scsi_sense_key_string().
Fixes: 655ee63cf371 ("[SCSI] scsi constants: command, sense key + additional sense strings")
Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
Changes since v1:
- Addressed Bart's comments
- Moved opening function brace to match kernel style guidelines
- Changed upperbounds check to use ARRAY_SIZE instead of fixed value
drivers/scsi/constants.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 83458f7..6dc96c8 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -361,8 +361,9 @@ static const char * const snstext[] = {
/* Get sense key string or NULL if not available */
const char *
-scsi_sense_key_string(unsigned char key) {
- if (key <= 0xE)
+scsi_sense_key_string(unsigned char key)
+{
+ if (key < ARRAY_SIZE(snstext))
return snstext[key];
return NULL;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] scsi: fix upper bounds check of sense key in scsi_sense_key_string()
2016-08-12 22:20 [PATCH v2] scsi: fix upper bounds check of sense key in scsi_sense_key_string() Tyrel Datwyler
@ 2016-08-16 4:51 ` Martin K. Petersen
0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2016-08-16 4:51 UTC (permalink / raw)
To: Tyrel Datwyler
Cc: james.bottomley, martin.petersen, linux-scsi, bart.vanassche
>>>>> "Tyrel" == Tyrel Datwyler <tyreld@linux.vnet.ibm.com> writes:
Tyrel> Commit 655ee63cf371 added a "Completed" sense string with key 0xF
Tyrel> to snstext[], but failed to updated the upper bounds check of the
Tyrel> sense key in scsi_sense_key_string().
Applied to 4.8/scsi-fixes.
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-08-16 4:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-12 22:20 [PATCH v2] scsi: fix upper bounds check of sense key in scsi_sense_key_string() Tyrel Datwyler
2016-08-16 4:51 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).