]> git.karo-electronics.de Git - linux-beck.git/commitdiff
scsi: fix upper bounds check of sense key in scsi_sense_key_string()
authorTyrel Datwyler <tyreld@linux.vnet.ibm.com>
Fri, 12 Aug 2016 22:20:07 +0000 (17:20 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 16 Aug 2016 04:49:32 +0000 (00:49 -0400)
Commit 655ee63cf371 ("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: 655ee63cf371 ("[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>
drivers/scsi/constants.c

index 83458f7a28248045bdca6f1b5603fac7ce6a84f2..6dc96c8dfe75c229e522db72b587bd1af5852686 100644 (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;
 }