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

Commit 655ee63cf3 ("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: 655ee63cf3 ("[SCSI] scsi constants: command, sense key + additional sense strings")
Cc: <stable@vger.kernel.org> # v3.12+
Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Tyrel Datwyler 2016-08-12 17:20:07 -05:00 committed by Martin K. Petersen
parent e120dcb6b2
commit a87eeb900d
1 changed files with 3 additions and 2 deletions

View File

@ -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;
}