Commit cdcc2343fec00b3b364c0518ef2bb91587319407

Authored by James Smart
Committed by James Bottomley
1 parent 92e3af663a

[SCSI] lpfc 8.3.34: Fixed leaking memory from pci dma pool

Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>

Showing 2 changed files with 17 additions and 10 deletions Side-by-side Diff

drivers/scsi/lpfc/lpfc_hbadisc.c
... ... @@ -3509,7 +3509,7 @@
3509 3509 LPFC_MBOXQ_t *pmb = NULL;
3510 3510 MAILBOX_t *mb;
3511 3511 struct static_vport_info *vport_info;
3512   - int rc = 0, i;
  3512 + int mbx_wait_rc = 0, i;
3513 3513 struct fc_vport_identifiers vport_id;
3514 3514 struct fc_vport *new_fc_vport;
3515 3515 struct Scsi_Host *shost;
... ... @@ -3526,7 +3526,7 @@
3526 3526 " allocate mailbox memory\n");
3527 3527 return;
3528 3528 }
3529   -
  3529 + memset(pmb, 0, sizeof(LPFC_MBOXQ_t));
3530 3530 mb = &pmb->u.mb;
3531 3531  
3532 3532 vport_info = kzalloc(sizeof(struct static_vport_info), GFP_KERNEL);
3533 3533  
3534 3534  
3535 3535  
3536 3536  
... ... @@ -3540,24 +3540,31 @@
3540 3540  
3541 3541 vport_buff = (uint8_t *) vport_info;
3542 3542 do {
  3543 + /* free dma buffer from previous round */
  3544 + if (pmb->context1) {
  3545 + mp = (struct lpfc_dmabuf *)pmb->context1;
  3546 + lpfc_mbuf_free(phba, mp->virt, mp->phys);
  3547 + kfree(mp);
  3548 + }
3543 3549 if (lpfc_dump_static_vport(phba, pmb, offset))
3544 3550 goto out;
3545 3551  
3546 3552 pmb->vport = phba->pport;
3547   - rc = lpfc_sli_issue_mbox_wait(phba, pmb, LPFC_MBOX_TMO);
  3553 + mbx_wait_rc = lpfc_sli_issue_mbox_wait(phba, pmb,
  3554 + LPFC_MBOX_TMO);
3548 3555  
3549   - if ((rc != MBX_SUCCESS) || mb->mbxStatus) {
  3556 + if ((mbx_wait_rc != MBX_SUCCESS) || mb->mbxStatus) {
3550 3557 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
3551 3558 "0544 lpfc_create_static_vport failed to"
3552 3559 " issue dump mailbox command ret 0x%x "
3553 3560 "status 0x%x\n",
3554   - rc, mb->mbxStatus);
  3561 + mbx_wait_rc, mb->mbxStatus);
3555 3562 goto out;
3556 3563 }
3557 3564  
3558 3565 if (phba->sli_rev == LPFC_SLI_REV4) {
3559 3566 byte_count = pmb->u.mqe.un.mb_words[5];
3560   - mp = (struct lpfc_dmabuf *) pmb->context2;
  3567 + mp = (struct lpfc_dmabuf *)pmb->context1;
3561 3568 if (byte_count > sizeof(struct static_vport_info) -
3562 3569 offset)
3563 3570 byte_count = sizeof(struct static_vport_info)
... ... @@ -3621,9 +3628,9 @@
3621 3628  
3622 3629 out:
3623 3630 kfree(vport_info);
3624   - if (rc != MBX_TIMEOUT) {
3625   - if (pmb->context2) {
3626   - mp = (struct lpfc_dmabuf *) pmb->context2;
  3631 + if (mbx_wait_rc != MBX_TIMEOUT) {
  3632 + if (pmb->context1) {
  3633 + mp = (struct lpfc_dmabuf *)pmb->context1;
3627 3634 lpfc_mbuf_free(phba, mp->virt, mp->phys);
3628 3635 kfree(mp);
3629 3636 }
drivers/scsi/lpfc/lpfc_mbox.c
... ... @@ -92,7 +92,7 @@
92 92 memset(mp->virt, 0, LPFC_BPL_SIZE);
93 93 INIT_LIST_HEAD(&mp->list);
94 94 /* save address for completion */
95   - pmb->context2 = (uint8_t *) mp;
  95 + pmb->context1 = (uint8_t *)mp;
96 96 mb->un.varWords[3] = putPaddrLow(mp->phys);
97 97 mb->un.varWords[4] = putPaddrHigh(mp->phys);
98 98 mb->un.varDmp.sli4_length = sizeof(struct static_vport_info);