Skip to content

Commit

Permalink
scsi: fix upper bounds check of sense key in scsi_sense_key_string()
Browse files Browse the repository at this point in the history
Commit 655ee63 ("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: 655ee63 ("[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>
  • Loading branch information
Tyrel Datwyler authored and Martin K. Petersen committed Aug 16, 2016
1 parent e120dcb commit a87eeb9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/scsi/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a87eeb9

Please sign in to comment.