Skip to content

Commit

Permalink
[SCSI] lpfc 8.3.10: Fix Initialization issues
Browse files Browse the repository at this point in the history
- Add NULL checks to the pointers for the config_async mailbox
  and dump_wakeup_params mailbox.
- Add code to check return value of lpfc_read_sparams everywhere
  and handle failures appropriately.

Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
  • Loading branch information
James Smart authored and James Bottomley committed Mar 3, 2010
1 parent 43aebfa commit 9f1177a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 18 deletions.
32 changes: 18 additions & 14 deletions drivers/scsi/lpfc/lpfc_hbadisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2024,8 +2024,6 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
int rc;
struct fcf_record *fcf_record;

sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);

spin_lock_irq(&phba->hbalock);
switch (la->UlnkSpeed) {
case LA_1GHZ_LINK:
Expand Down Expand Up @@ -2117,18 +2115,24 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
spin_unlock_irq(&phba->hbalock);

lpfc_linkup(phba);
if (sparam_mbox) {
lpfc_read_sparam(phba, sparam_mbox, 0);
sparam_mbox->vport = vport;
sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;
rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT);
if (rc == MBX_NOT_FINISHED) {
mp = (struct lpfc_dmabuf *) sparam_mbox->context1;
lpfc_mbuf_free(phba, mp->virt, mp->phys);
kfree(mp);
mempool_free(sparam_mbox, phba->mbox_mem_pool);
goto out;
}
sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
if (!sparam_mbox)
goto out;

rc = lpfc_read_sparam(phba, sparam_mbox, 0);
if (rc) {
mempool_free(sparam_mbox, phba->mbox_mem_pool);
goto out;
}
sparam_mbox->vport = vport;
sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;
rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT);
if (rc == MBX_NOT_FINISHED) {
mp = (struct lpfc_dmabuf *) sparam_mbox->context1;
lpfc_mbuf_free(phba, mp->virt, mp->phys);
kfree(mp);
mempool_free(sparam_mbox, phba->mbox_mem_pool);
goto out;
}

if (!(phba->hba_flag & HBA_FCOE_SUPPORT)) {
Expand Down
19 changes: 17 additions & 2 deletions drivers/scsi/lpfc/lpfc_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,12 @@ lpfc_config_port_post(struct lpfc_hba *phba)
mb = &pmb->u.mb;

/* Get login parameters for NID. */
lpfc_read_sparam(phba, pmb, 0);
rc = lpfc_read_sparam(phba, pmb, 0);
if (rc) {
mempool_free(pmb, phba->mbox_mem_pool);
return -ENOMEM;
}

pmb->vport = vport;
if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
Expand All @@ -359,7 +364,7 @@ lpfc_config_port_post(struct lpfc_hba *phba)
mb->mbxCommand, mb->mbxStatus);
phba->link_state = LPFC_HBA_ERROR;
mp = (struct lpfc_dmabuf *) pmb->context1;
mempool_free( pmb, phba->mbox_mem_pool);
mempool_free(pmb, phba->mbox_mem_pool);
lpfc_mbuf_free(phba, mp->virt, mp->phys);
kfree(mp);
return -EIO;
Expand Down Expand Up @@ -571,6 +576,11 @@ lpfc_config_port_post(struct lpfc_hba *phba)
}
/* MBOX buffer will be freed in mbox compl */
pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
if (!pmb) {
phba->link_state = LPFC_HBA_ERROR;
return -ENOMEM;
}

lpfc_config_async(phba, pmb, LPFC_ELS_RING);
pmb->mbox_cmpl = lpfc_config_async_cmpl;
pmb->vport = phba->pport;
Expand All @@ -588,6 +598,11 @@ lpfc_config_port_post(struct lpfc_hba *phba)

/* Get Option rom version */
pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
if (!pmb) {
phba->link_state = LPFC_HBA_ERROR;
return -ENOMEM;
}

lpfc_dump_wakeup_param(phba, pmb);
pmb->mbox_cmpl = lpfc_dump_wakeup_param_cmpl;
pmb->vport = phba->pport;
Expand Down
8 changes: 7 additions & 1 deletion drivers/scsi/lpfc/lpfc_sli.c
Original file line number Diff line number Diff line change
Expand Up @@ -4388,7 +4388,13 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
spin_unlock_irq(&phba->hbalock);

/* Read the port's service parameters. */
lpfc_read_sparam(phba, mboxq, vport->vpi);
rc = lpfc_read_sparam(phba, mboxq, vport->vpi);
if (rc) {
phba->link_state = LPFC_HBA_ERROR;
rc = -ENOMEM;
goto out_free_vpd;
}

mboxq->vport = vport;
rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
mp = (struct lpfc_dmabuf *) mboxq->context1;
Expand Down
7 changes: 6 additions & 1 deletion drivers/scsi/lpfc/lpfc_vport.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ lpfc_vport_sparm(struct lpfc_hba *phba, struct lpfc_vport *vport)
}
mb = &pmb->u.mb;

lpfc_read_sparam(phba, pmb, vport->vpi);
rc = lpfc_read_sparam(phba, pmb, vport->vpi);
if (rc) {
mempool_free(pmb, phba->mbox_mem_pool);
return -ENOMEM;
}

/*
* Grab buffer pointer and clear context1 so we can use
* lpfc_sli_issue_box_wait
Expand Down

0 comments on commit 9f1177a

Please sign in to comment.