diff mbox series

[3/8] qla2xxx: klocwork - Check for a valid fcport pointer

Message ID 20230518075841.40363-4-njavali@marvell.com
State New
Headers show
Series qla2xxx klocwork fixes | expand

Commit Message

Nilesh Javali May 18, 2023, 7:58 a.m. UTC
Klocwork reported warning of null pointer may be dereferenced.
The routine exits when sa_ctl is NULL and fcport is allocated after
the exit call thus causing NULL fcport pointer to dereference at the
time of exit.

Add a check for a valid fcport pointer at the time of exit.

Cc: stable@vger.kernel.org
Signed-off-by: Nilesh Javali <njavali@marvell.com>
---
 drivers/scsi/qla2xxx/qla_edif.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_edif.c b/drivers/scsi/qla2xxx/qla_edif.c
index ec0e20255bd3..14e314c12dd6 100644
--- a/drivers/scsi/qla2xxx/qla_edif.c
+++ b/drivers/scsi/qla2xxx/qla_edif.c
@@ -2411,7 +2411,8 @@  qla24xx_issue_sa_replace_iocb(scsi_qla_host_t *vha, struct qla_work_evt *e)
 	kref_put(&sp->cmd_kref, qla2x00_sp_release);
 	fcport->flags &= ~FCF_ASYNC_SENT;
 done:
-	fcport->flags &= ~FCF_ASYNC_ACTIVE;
+	if (fcport)
+		fcport->flags &= ~FCF_ASYNC_ACTIVE;
 	return rval;
 }