1. 04 Apr, 2019 2 commits
  2. 28 Mar, 2019 33 commits
  3. 26 Mar, 2019 5 commits
    • Nathan Chancellor's avatar
      scsi: gdth: Only call dma_free_coherent when buf is not NULL in ioc_general · 3e14592d
      Nathan Chancellor authored
      When building with -Wsometimes-uninitialized, Clang warns:
      
      drivers/scsi/gdth.c:3662:6: warning: variable 'paddr' is used
      uninitialized whenever 'if' condition is false
      [-Wsometimes-uninitialized]
      
      Don't attempt to call dma_free_coherent when buf is NULL (meaning that
      we never called dma_alloc_coherent and initialized paddr), which avoids
      this warning.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/402Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      3e14592d
    • YueHaibing's avatar
      scsi: pm8001: remove set but not used variables 'param, sas_ha' · a4b207de
      YueHaibing authored
      Fixes gcc '-Wunused-but-set-variable' warning:
      
      drivers/scsi/pm8001/pm8001_hwi.c: In function 'mpi_smp_completion':
      drivers/scsi/pm8001/pm8001_hwi.c:2901:6: warning:
       variable 'param' set but not used [-Wunused-but-set-variable]
      
      drivers/scsi/pm8001/pm8001_hwi.c: In function 'pm8001_bytes_dmaed':
      drivers/scsi/pm8001/pm8001_hwi.c:3247:24: warning:
       variable 'sas_ha' set but not used [-Wunused-but-set-variable]
      
      They're never used since introduction, so can be removed.
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Acked-by: default avatarJack Wang <jinpu.wang@cloud.ionos.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      a4b207de
    • Arnd Bergmann's avatar
      scsi: qla4xxx: avoid freeing unallocated dma memory · 608f729c
      Arnd Bergmann authored
      Clang -Wuninitialized notices that on is_qla40XX we never allocate any DMA
      memory in get_fw_boot_info() but attempt to free it anyway:
      
      drivers/scsi/qla4xxx/ql4_os.c:5915:7: error: variable 'buf_dma' is used uninitialized whenever 'if' condition is false
            [-Werror,-Wsometimes-uninitialized]
                      if (!(val & 0x07)) {
                          ^~~~~~~~~~~~~
      drivers/scsi/qla4xxx/ql4_os.c:5985:47: note: uninitialized use occurs here
              dma_free_coherent(&ha->pdev->dev, size, buf, buf_dma);
                                                           ^~~~~~~
      drivers/scsi/qla4xxx/ql4_os.c:5915:3: note: remove the 'if' if its condition is always true
                      if (!(val & 0x07)) {
                      ^~~~~~~~~~~~~~~~~~~
      drivers/scsi/qla4xxx/ql4_os.c:5885:20: note: initialize the variable 'buf_dma' to silence this warning
              dma_addr_t buf_dma;
                                ^
                                 = 0
      
      Skip the call to dma_free_coherent() here.
      
      Fixes: 2a991c21 ("[SCSI] qla4xxx: Boot from SAN support for open-iscsi")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      608f729c
    • Arnd Bergmann's avatar
      scsi: lpfc: avoid uninitialized variable warning · faf5a744
      Arnd Bergmann authored
      clang -Wuninitialized incorrectly sees a variable being used without
      initialization:
      
      drivers/scsi/lpfc/lpfc_nvme.c:2102:37: error: variable 'localport' is uninitialized when used here
            [-Werror,-Wuninitialized]
                      lport = (struct lpfc_nvme_lport *)localport->private;
                                                        ^~~~~~~~~
      drivers/scsi/lpfc/lpfc_nvme.c:2059:38: note: initialize the variable 'localport' to silence this warning
              struct nvme_fc_local_port *localport;
                                                  ^
                                                   = NULL
      1 error generated.
      
      This is clearly in dead code, as the condition leading up to it is always
      false when CONFIG_NVME_FC is disabled, and the variable is always
      initialized when nvme_fc_register_localport() got called successfully.
      
      Change the preprocessor conditional to the equivalent C construct, which
      makes the code more readable and gets rid of the warning.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarJames Smart <james.smart@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      faf5a744
    • Silvio Cesare's avatar
      scsi: lpfc: change snprintf to scnprintf for possible overflow · e7f7b6f3
      Silvio Cesare authored
      Change snprintf to scnprintf. There are generally two cases where using
      snprintf causes problems.
      
      1) Uses of size += snprintf(buf, SIZE - size, fmt, ...)
      In this case, if snprintf would have written more characters than what the
      buffer size (SIZE) is, then size will end up larger than SIZE. In later
      uses of snprintf, SIZE - size will result in a negative number, leading
      to problems. Note that size might already be too large by using
      size = snprintf before the code reaches a case of size += snprintf.
      
      2) If size is ultimately used as a length parameter for a copy back to user
      space, then it will potentially allow for a buffer overflow and information
      disclosure when size is greater than SIZE. When the size is used to index
      the buffer directly, we can have memory corruption. This also means when
      size = snprintf... is used, it may also cause problems since size may become
      large.  Copying to userspace is mitigated by the HARDENED_USERCOPY kernel
      configuration.
      
      The solution to these issues is to use scnprintf which returns the number of
      characters actually written to the buffer, so the size variable will never
      exceed SIZE.
      Signed-off-by: default avatarSilvio Cesare <silvio.cesare@gmail.com>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      Signed-off-by: default avatarJames Smart <james.smart@broadcom.com>
      Cc: Dick Kennedy <dick.kennedy@broadcom.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Greg KH <greg@kroah.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      e7f7b6f3