[PATCH] scsi: qedf: fix a memleak in qedf_alloc_global_queues

Dinghao Liu posted 1 patch 2 years ago
drivers/scsi/qedf/qedf_main.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] scsi: qedf: fix a memleak in qedf_alloc_global_queues
Posted by Dinghao Liu 2 years ago
When qedf_alloc_bdq() fails, qedf->global_queues should
be freed to prevent potential memleak. It's the same for
the following error handling paths.

Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/scsi/qedf/qedf_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index a58353b7b4e8..2261efcf2dbb 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -3155,6 +3155,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf)
 
 mem_alloc_failure:
 	qedf_free_global_queues(qedf);
+	kfree(qedf->global_queues);
 	return status;
 }
 
-- 
2.17.1