scsi: lpfc: Fix lpfc_io_buf resource leak in lpfc_get_scsi_buf_s4 error path
authorJames Smart <jsmart2021@gmail.com>
Tue, 28 Jan 2020 00:23:02 +0000 (16:23 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 11 Feb 2020 03:46:55 +0000 (22:46 -0500)
If a call to lpfc_get_cmd_rsp_buf_per_hdwq returns NULL (memory allocation
failure), a previously allocated lpfc_io_buf resource is leaked.

Fix by releasing the lpfc_io_buf resource in the failure path.

Fixes: d79c9e9d4b3d ("scsi: lpfc: Support dynamic unbounded SGL lists on G7 hardware.")
Cc: <stable@vger.kernel.org> # v5.4+
Link: https://lore.kernel.org/r/20200128002312.16346-3-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc_scsi.c

index 2c7e0b22db2f14211126066afe9af18ae6e04809..96ac4a154c580cdb69b1322949a0ad4de8171cd9 100644 (file)
@@ -671,8 +671,10 @@ lpfc_get_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
        lpfc_cmd->prot_data_type = 0;
 #endif
        tmp = lpfc_get_cmd_rsp_buf_per_hdwq(phba, lpfc_cmd);
-       if (!tmp)
+       if (!tmp) {
+               lpfc_release_io_buf(phba, lpfc_cmd, lpfc_cmd->hdwq);
                return NULL;
+       }
 
        lpfc_cmd->fcp_cmnd = tmp->fcp_cmnd;
        lpfc_cmd->fcp_rsp = tmp->fcp_rsp;