scsi: set fmt to NULL scsi_extd_sense_format() by default
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 2 Dec 2014 11:07:30 +0000 (14:07 +0300)
committerChristoph Hellwig <hch@lst.de>
Tue, 2 Dec 2014 17:26:52 +0000 (18:26 +0100)
One of the two callers passes an unintialized pointer as "fmt" and
expects it to be set to NULL if there is no format string.  Let's make
this function work as expected.

Fixes: d811b848ebb7 ('scsi: use sdev as argument for sense code printing')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/scsi/constants.c

index aee62f60b43d90d3ec327a6d5fc999ecd2faaa5d..e2068a2621c4ee12302c9d745f5c5aca988dccf7 100644 (file)
@@ -1271,6 +1271,7 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt)
        int i;
        unsigned short code = ((asc << 8) | ascq);
 
+       *fmt = NULL;
        for (i = 0; additional[i].text; i++)
                if (additional[i].code12 == code)
                        return additional[i].text;
@@ -1282,6 +1283,8 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt)
                        return additional2[i].str;
                }
        }
+#else
+       *fmt = NULL;
 #endif
        return NULL;
 }