• James Smart's avatar
    scsi: lpfc: Fix various issues reported by tools · a4de8356
    James Smart authored
    This patch fixes below Smatch reported issues:
    
     1. lpfc_hbadisc.c:3020 lpfc_mbx_cmpl_fcf_rr_read_fcf_rec()
        error: uninitialized symbol 'vlan_id'.
    
     2. lpfc_hbadisc.c:3121 lpfc_mbx_cmpl_read_fcf_rec()
        error: uninitialized symbol 'vlan_id'.
    
     3. lpfc_init.c:335 lpfc_dump_wakeup_param_cmpl()
        warn: always true condition '(prg->dist < 4) => (0-3 < 4)'
    
     4. lpfc_init.c:2419 lpfc_parse_vpd()
        warn: inconsistent indenting.
    
     5. lpfc_init.c:13248 lpfc_sli4_enable_msi()
        warn: 'phba->pcidev->irq' 2147483648 can't fit into 65535
        'eqhdl->irq'
    
     6. lpfc_debugfs.c:5300 lpfc_idiag_extacc_avail_get()
        error: uninitialized symbol 'ext_cnt'
    
     7. lpfc_debugfs.c:5300 lpfc_idiag_extacc_avail_get()
        error: uninitialized symbol 'ext_size'
    
     8. lpfc_vmid.c:248 lpfc_vmid_get_appid()
        warn: sleeping in atomic context.
    
     9. lpfc_init.c:8342 lpfc_sli4_driver_resource_setup()
        warn: missing error code 'rc'.
    
    10. lpfc_init.c:13573 lpfc_sli4_hba_unset()
        warn: variable dereferenced before check 'phba->pport' (see
        line 13546)
    
    11. lpfc_auth.c:1923 lpfc_auth_handle_dhchap_reply()
        error: double free of 'hash_value'
    
    Fixes:
    
     1. Initialize vlan_id to LPFC_FCOE_NULL_VID.
    
     2. Initialize vlan_id to LPFC_FCOE_NULL_VID.
    
     3. prg->dist is a 2 bit field. Its value can only be between 0-3.
        Remove redundent check 'if (prg->dist < 4)'.
    
     4. Fix inconsistent indenting.  Moved logic into helper function
        lpfc_fill_vpd().
    
     5. Define 'eqhdl->irq' as int value as pci_irq_vector() returns int.
        Also, check for return value of pci_irq_vector() and log message in
        case of failure.
    
     6. Initialize 'ext_cnt' to 0.
    
     7. Initialize 'ext_size' to 0.
    
     8. Use alloc_percpu_gfp() with GFP_ATOMIC flag.
    
     9. 'rc' was not updated when dma_pool_create() fails.  Update 'rc =
         -ENOMEM' when dma_pool_create() fails before calling goto statement.
    
    10. Add check for 'phba->pport' in lpfc_cpuhp_remove().
    
    11. Initialize 'hash_value' to NULL, same like 'aug_chal' variable.
    
    Link: https://lore.kernel.org/r/20220911221505.117655-13-jsmart2021@gmail.comCo-developed-by: default avatarJustin Tee <justin.tee@broadcom.com>
    Signed-off-by: default avatarJustin Tee <justin.tee@broadcom.com>
    Signed-off-by: default avatarJames Smart <jsmart2021@gmail.com>
    Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
    a4de8356
lpfc_sli.c 680 KB