scsi: qla2xxx: silence -Wformat-security warning
authorNicolas Iooss <nicolas.iooss_linux@m4x.org>
Mon, 26 Dec 2016 13:23:09 +0000 (14:23 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 10 Jan 2017 04:17:27 +0000 (23:17 -0500)
qla24xx_enable_msix() calls scnprintf() with a non-literal format
string. This makes clang report -Wformat-security warnings when
compiling this function:

    drivers/scsi/qla2xxx/qla_isr.c:3083:7: error: format string is not a
    string literal (potentially insecure) [-Werror,-Wformat-security]
                        msix_entries[i].name);
                        ^~~~~~~~~~~~~~~~~~~~
    drivers/scsi/qla2xxx/qla_isr.c:3083:7: note: treat the string as an
    argument to avoid this
                        msix_entries[i].name);
                        ^
                        "%s",
    drivers/scsi/qla2xxx/qla_isr.c:3119:7: error: format string is not a
    string literal (potentially insecure) [-Werror,-Wformat-security]
                        msix_entries[QLA_ATIO_VECTOR].name);
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/scsi/qla2xxx/qla_isr.c:3119:7: note: treat the string as an
    argument to avoid this
                        msix_entries[QLA_ATIO_VECTOR].name);
                        ^
                        "%s",

Even though msix_entries[...].name are initialized as literal strings
with no % character and are never modified, introduce a "%s" format
parameter in order to silence this -Wformat-security warning and make
clang able to detect at compile time real bugs related to string
formatting.

[mkp: typo]

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Acked-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/qla2xxx/qla_isr.c

index 5093ca9b02ec52c8e70674f88205941cc0967d9f..474b415217df5f7c4a4cc55d48fb12b287719e8d 100644 (file)
@@ -3080,7 +3080,7 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
                qentry->handle = rsp;
                rsp->msix = qentry;
                scnprintf(qentry->name, sizeof(qentry->name),
-                   msix_entries[i].name);
+                   "%s", msix_entries[i].name);
                if (IS_P3P_TYPE(ha))
                        ret = request_irq(qentry->vector,
                                qla82xx_msix_entries[i].handler,
@@ -3116,7 +3116,7 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
                rsp->msix = qentry;
                qentry->handle = rsp;
                scnprintf(qentry->name, sizeof(qentry->name),
-                   msix_entries[QLA_ATIO_VECTOR].name);
+                   "%s", msix_entries[QLA_ATIO_VECTOR].name);
                qentry->in_use = 1;
                ret = request_irq(qentry->vector,
                        msix_entries[QLA_ATIO_VECTOR].handler,