lkml.org 
[lkml]   [2023]   [Apr]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] qedf: Fix NULL dereference in error handling
Date
Smatch reported:

drivers/scsi/qedf/qedf_main.c:3056 qedf_alloc_global_queues()
warn: missing unwind goto?

At this point in the function, nothing has been allocated so we can
return directly. In particular the "qedf->global_queues" have not been
allocated so calling qedf_free_global_queues() will lead to a NULL
dereference when we check if (!gl[i]) and "gl" is NULL.

Fixes: 09e062ce83cb ("qedf: Fix NULL dereference in error handling")
Signed-off-by: Jinhong Zhu <jinhongzhu@hust.edu.cn>
Reviewed-by: Dan Carpenter <error27@gmail.com>
---
drivers/scsi/qedf/qedf_main.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 35e16600fc63..f2c7dd4db9c6 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -3043,9 +3043,8 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf)
* addresses of our queues
*/
if (!qedf->p_cpuq) {
- status = -EINVAL;
QEDF_ERR(&qedf->dbg_ctx, "p_cpuq is NULL.\n");
- goto mem_alloc_failure;
+ return -EINVAL;
}

qedf->global_queues = kzalloc((sizeof(struct global_queue *)
--
2.34.1
\
 
 \ /
  Last update: 2023-04-17 15:57    [W:0.064 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site