Commit 15091875 authored by Zhen Lei's avatar Zhen Lei Committed by Luo Gengkun
Browse files

scsi: qedf: Fix a possible memory leak in qedf_alloc_and_init_sb()

stable inclusion
from stable-v6.6.64
commit 7c1832287b21ff68c4e3625e63cc7619edf5908b
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBEGFD
CVE: CVE-2024-56748

Reference: https://git.kernel.org/stable/c/7c1832287b21ff68c4e3625e63cc7619edf5908b



--------------------------------

[ Upstream commit c62c30429db3eb4ced35c7fcf6f04a61ce3a01bb ]

Hook "qed_ops->common->sb_init = qed_sb_init" does not release the DMA
memory sb_virt when it fails. Add dma_free_coherent() to free it. This
is the same way as qedr_alloc_mem_sb() and qede_alloc_mem_sb().

Fixes: 61d8658b ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
Link: https://lore.kernel.org/r/20241026125711.484-2-thunder.leizhen@huawei.com


Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarLuo Gengkun <luogengkun2@huawei.com>
parent 5672a2cb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2737,6 +2737,7 @@ static int qedf_alloc_and_init_sb(struct qedf_ctx *qedf,
	    sb_id, QED_SB_TYPE_STORAGE);

	if (ret) {
		dma_free_coherent(&qedf->pdev->dev, sizeof(*sb_virt), sb_virt, sb_phys);
		QEDF_ERR(&qedf->dbg_ctx,
			 "Status block initialization failed (0x%x) for id = %d.\n",
			 ret, sb_id);