]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: qedi: Fix a possible memory leak in qedi_alloc_and_init_sb()
authorZhen Lei <thunder.leizhen@huawei.com>
Sat, 26 Oct 2024 12:57:11 +0000 (20:57 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Dec 2024 12:53:39 +0000 (13:53 +0100)
[ Upstream commit 95bbdca4999bc59a72ebab01663d421d6ce5775d ]

Hook "qedi_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: ace7f46ba5fd ("scsi: qedi: Add QLogic FastLinQ offload iSCSI driver framework.")
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Link: https://lore.kernel.org/r/20241026125711.484-3-thunder.leizhen@huawei.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/qedi/qedi_main.c

index cd0180b1f5b9dad5d8be7019ba0e2675430f543e..ede8d1f6ae23614f1cdda158eef649da8b745951 100644 (file)
@@ -369,6 +369,7 @@ static int qedi_alloc_and_init_sb(struct qedi_ctx *qedi,
        ret = qedi_ops->common->sb_init(qedi->cdev, sb_info, sb_virt, sb_phys,
                                       sb_id, QED_SB_TYPE_STORAGE);
        if (ret) {
+               dma_free_coherent(&qedi->pdev->dev, sizeof(*sb_virt), sb_virt, sb_phys);
                QEDI_ERR(&qedi->dbg_ctx,
                         "Status block initialization failed for id = %d.\n",
                          sb_id);