Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cdcc2343 authored by James Smart's avatar James Smart Committed by James Bottomley
Browse files

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

parent 92e3af66
Loading
Loading
Loading
Loading
+16 −9
Original line number Original line Diff line number Diff line
@@ -3509,7 +3509,7 @@ lpfc_create_static_vport(struct lpfc_hba *phba)
	LPFC_MBOXQ_t *pmb = NULL;
	LPFC_MBOXQ_t *pmb = NULL;
	MAILBOX_t *mb;
	MAILBOX_t *mb;
	struct static_vport_info *vport_info;
	struct static_vport_info *vport_info;
	int rc = 0, i;
	int mbx_wait_rc = 0, i;
	struct fc_vport_identifiers vport_id;
	struct fc_vport_identifiers vport_id;
	struct fc_vport *new_fc_vport;
	struct fc_vport *new_fc_vport;
	struct Scsi_Host *shost;
	struct Scsi_Host *shost;
@@ -3526,7 +3526,7 @@ lpfc_create_static_vport(struct lpfc_hba *phba)
				" allocate mailbox memory\n");
				" allocate mailbox memory\n");
		return;
		return;
	}
	}

	memset(pmb, 0, sizeof(LPFC_MBOXQ_t));
	mb = &pmb->u.mb;
	mb = &pmb->u.mb;


	vport_info = kzalloc(sizeof(struct static_vport_info), GFP_KERNEL);
	vport_info = kzalloc(sizeof(struct static_vport_info), GFP_KERNEL);
@@ -3540,24 +3540,31 @@ lpfc_create_static_vport(struct lpfc_hba *phba)


	vport_buff = (uint8_t *) vport_info;
	vport_buff = (uint8_t *) vport_info;
	do {
	do {
		/* free dma buffer from previous round */
		if (pmb->context1) {
			mp = (struct lpfc_dmabuf *)pmb->context1;
			lpfc_mbuf_free(phba, mp->virt, mp->phys);
			kfree(mp);
		}
		if (lpfc_dump_static_vport(phba, pmb, offset))
		if (lpfc_dump_static_vport(phba, pmb, offset))
			goto out;
			goto out;


		pmb->vport = phba->pport;
		pmb->vport = phba->pport;
		rc = lpfc_sli_issue_mbox_wait(phba, pmb, LPFC_MBOX_TMO);
		mbx_wait_rc = lpfc_sli_issue_mbox_wait(phba, pmb,
							LPFC_MBOX_TMO);


		if ((rc != MBX_SUCCESS) || mb->mbxStatus) {
		if ((mbx_wait_rc != MBX_SUCCESS) || mb->mbxStatus) {
			lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
			lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
				"0544 lpfc_create_static_vport failed to"
				"0544 lpfc_create_static_vport failed to"
				" issue dump mailbox command ret 0x%x "
				" issue dump mailbox command ret 0x%x "
				"status 0x%x\n",
				"status 0x%x\n",
				rc, mb->mbxStatus);
				mbx_wait_rc, mb->mbxStatus);
			goto out;
			goto out;
		}
		}


		if (phba->sli_rev == LPFC_SLI_REV4) {
		if (phba->sli_rev == LPFC_SLI_REV4) {
			byte_count = pmb->u.mqe.un.mb_words[5];
			byte_count = pmb->u.mqe.un.mb_words[5];
			mp = (struct lpfc_dmabuf *) pmb->context2;
			mp = (struct lpfc_dmabuf *)pmb->context1;
			if (byte_count > sizeof(struct static_vport_info) -
			if (byte_count > sizeof(struct static_vport_info) -
					offset)
					offset)
				byte_count = sizeof(struct static_vport_info)
				byte_count = sizeof(struct static_vport_info)
@@ -3621,9 +3628,9 @@ lpfc_create_static_vport(struct lpfc_hba *phba)


out:
out:
	kfree(vport_info);
	kfree(vport_info);
	if (rc != MBX_TIMEOUT) {
	if (mbx_wait_rc != MBX_TIMEOUT) {
		if (pmb->context2) {
		if (pmb->context1) {
			mp = (struct lpfc_dmabuf *) pmb->context2;
			mp = (struct lpfc_dmabuf *)pmb->context1;
			lpfc_mbuf_free(phba, mp->virt, mp->phys);
			lpfc_mbuf_free(phba, mp->virt, mp->phys);
			kfree(mp);
			kfree(mp);
		}
		}
+1 −1
Original line number Original line Diff line number Diff line
@@ -92,7 +92,7 @@ lpfc_dump_static_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb,
	memset(mp->virt, 0, LPFC_BPL_SIZE);
	memset(mp->virt, 0, LPFC_BPL_SIZE);
	INIT_LIST_HEAD(&mp->list);
	INIT_LIST_HEAD(&mp->list);
	/* save address for completion */
	/* save address for completion */
	pmb->context2 = (uint8_t *) mp;
	pmb->context1 = (uint8_t *)mp;
	mb->un.varWords[3] = putPaddrLow(mp->phys);
	mb->un.varWords[3] = putPaddrLow(mp->phys);
	mb->un.varWords[4] = putPaddrHigh(mp->phys);
	mb->un.varWords[4] = putPaddrHigh(mp->phys);
	mb->un.varDmp.sli4_length = sizeof(struct static_vport_info);
	mb->un.varDmp.sli4_length = sizeof(struct static_vport_info);