[PATCH] scsi: qedi: Fix potential undefined behavior by replacing goto with return

Jiasheng Jiang posted 1 patch 2 months ago
drivers/scsi/qedi/qedi_main.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] scsi: qedi: Fix potential undefined behavior by replacing goto with return
Posted by Jiasheng Jiang 2 months ago
If "!qedi->p_cpuq" evaluates to true, qedi->global_queues will be freed
without being initialized, potentially causing undefined behavior.

Fixes: ace7f46ba5fd ("scsi: qedi: Add QLogic FastLinQ offload iSCSI driver framework.")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
---
 drivers/scsi/qedi/qedi_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
index b168bb2178e9..23e346a3e5fd 100644
--- a/drivers/scsi/qedi/qedi_main.c
+++ b/drivers/scsi/qedi/qedi_main.c
@@ -1639,8 +1639,7 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi)
 	 * addresses of our queues
 	 */
 	if (!qedi->p_cpuq) {
-		status = -EINVAL;
-		goto mem_alloc_failure;
+		return -EINVAL;
 	}
 
 	qedi->global_queues = kzalloc((sizeof(struct global_queue *) *
-- 
2.25.1