Commit e594d5ae authored by Tyrel Datwyler's avatar Tyrel Datwyler Committed by Ben Hutchings

scsi: fix upper bounds check of sense key in scsi_sense_key_string()

commit a87eeb90 upstream.

Commit 655ee63c ("scsi constants: command, sense key + additional
sense string") 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: 655ee63c ("[SCSI] scsi constants: command, sense key + additional sense strings")
Signed-off-by: default avatarTyrel Datwyler <tyreld@linux.vnet.ibm.com>
Reviewed-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent f0cee622
......@@ -1335,9 +1335,10 @@ static const char * const snstext[] = {
/* Get sense key string or NULL if not available */
const char *
scsi_sense_key_string(unsigned char key) {
scsi_sense_key_string(unsigned char key)
{
#ifdef CONFIG_SCSI_CONSTANTS
if (key <= 0xE)
if (key < ARRAY_SIZE(snstext))
return snstext[key];
#endif
return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment