1. 26 Mar, 2019 5 commits
    • 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
    • Anders Roxell's avatar
      scsi: ufs-mediatek: Add missing MODULE_* information · 7766d129
      Anders Roxell authored
      When building the ufs-mediatek module the following warning shows up:
      
      WARNING: modpost: missing MODULE_LICENSE() in
        drivers/scsi/ufs/ufs-mediatek.o
      
      Rework to add MODULE_LICENSE,MODULE_AUTHOR and MODULE_DESCRIPTION.
      
      Fixes: ddd90623 ("scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips")
      Signed-off-by: default avatarAnders Roxell <anders.roxell@linaro.org>
      Reviewed-by: default avatarStanley Chu <stanley.chu@mediatek.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      7766d129
    • YueHaibing's avatar
      scsi: ufs-mediatek: Fix platform_no_drv_owner.cocci warnings · 3aa222cd
      YueHaibing authored
      Remove .owner field if calls are used which set it automatically
      Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Reviewed-by: default avatarStanley Chu <stanley.chu@mediatek.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      3aa222cd
  2. 21 Mar, 2019 7 commits
  3. 19 Mar, 2019 28 commits