scsi: lpfc: Fix resource leak in lpfc_sli4_send_seq_to_ulp()
[ Upstream commit 646db1a560f44236b7278b822ca99a1d3b6ea72c ] If no handler is found in lpfc_complete_unsol_iocb() to match the rctl of a received frame, the frame is dropped and resources are leaked. Fix by returning resources when discarding an unhandled frame type. Update lpfc_fc_frame_check() handling of NOP basic link service. Link: https://lore.kernel.org/r/20220426181419.9154-1-jsmart2021@gmail.com Co-developed-by: Justin Tee <justin.tee@broadcom.com> Signed-off-by: Justin Tee <justin.tee@broadcom.com> Signed-off-by: James Smart <jsmart2021@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
1869f9bfaf
commit
fa1b509d41
@@ -17445,7 +17445,6 @@ lpfc_fc_frame_check(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr)
|
|||||||
case FC_RCTL_ELS_REP: /* extended link services reply */
|
case FC_RCTL_ELS_REP: /* extended link services reply */
|
||||||
case FC_RCTL_ELS4_REQ: /* FC-4 ELS request */
|
case FC_RCTL_ELS4_REQ: /* FC-4 ELS request */
|
||||||
case FC_RCTL_ELS4_REP: /* FC-4 ELS reply */
|
case FC_RCTL_ELS4_REP: /* FC-4 ELS reply */
|
||||||
case FC_RCTL_BA_NOP: /* basic link service NOP */
|
|
||||||
case FC_RCTL_BA_ABTS: /* basic link service abort */
|
case FC_RCTL_BA_ABTS: /* basic link service abort */
|
||||||
case FC_RCTL_BA_RMC: /* remove connection */
|
case FC_RCTL_BA_RMC: /* remove connection */
|
||||||
case FC_RCTL_BA_ACC: /* basic accept */
|
case FC_RCTL_BA_ACC: /* basic accept */
|
||||||
@@ -17466,6 +17465,7 @@ lpfc_fc_frame_check(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr)
|
|||||||
fc_vft_hdr = (struct fc_vft_header *)fc_hdr;
|
fc_vft_hdr = (struct fc_vft_header *)fc_hdr;
|
||||||
fc_hdr = &((struct fc_frame_header *)fc_vft_hdr)[1];
|
fc_hdr = &((struct fc_frame_header *)fc_vft_hdr)[1];
|
||||||
return lpfc_fc_frame_check(phba, fc_hdr);
|
return lpfc_fc_frame_check(phba, fc_hdr);
|
||||||
|
case FC_RCTL_BA_NOP: /* basic link service NOP */
|
||||||
default:
|
default:
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
@@ -18284,12 +18284,14 @@ lpfc_sli4_send_seq_to_ulp(struct lpfc_vport *vport,
|
|||||||
if (!lpfc_complete_unsol_iocb(phba,
|
if (!lpfc_complete_unsol_iocb(phba,
|
||||||
phba->sli4_hba.els_wq->pring,
|
phba->sli4_hba.els_wq->pring,
|
||||||
iocbq, fc_hdr->fh_r_ctl,
|
iocbq, fc_hdr->fh_r_ctl,
|
||||||
fc_hdr->fh_type))
|
fc_hdr->fh_type)) {
|
||||||
lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
|
lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
|
||||||
"2540 Ring %d handler: unexpected Rctl "
|
"2540 Ring %d handler: unexpected Rctl "
|
||||||
"x%x Type x%x received\n",
|
"x%x Type x%x received\n",
|
||||||
LPFC_ELS_RING,
|
LPFC_ELS_RING,
|
||||||
fc_hdr->fh_r_ctl, fc_hdr->fh_type);
|
fc_hdr->fh_r_ctl, fc_hdr->fh_type);
|
||||||
|
lpfc_in_buf_free(phba, &seq_dmabuf->dbuf);
|
||||||
|
}
|
||||||
|
|
||||||
/* Free iocb created in lpfc_prep_seq */
|
/* Free iocb created in lpfc_prep_seq */
|
||||||
list_for_each_entry_safe(curr_iocb, next_iocb,
|
list_for_each_entry_safe(curr_iocb, next_iocb,
|
||||||
|
Reference in New Issue
Block a user