diff mbox series

[1/2] scsi: qla2xxx: Fix a memory leak in an error path of qla2x00_process_els()

Message ID 20211012191834.90306-2-jgu@purestorage.com (mailing list archive)
State Accepted
Headers show
Series scsi: qla2xxx: Fix bugs found by CodeSonar | expand

Commit Message

Joy Gu Oct. 12, 2021, 7:18 p.m. UTC
Commit 8c0eb596baa5 ("[SCSI] qla2xxx: Fix a memory leak in an error path of
qla2x00_process_els()"), intended to change

        bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN

to

        bsg_job->request->msgcode != FC_BSG_RPT_ELS

but changed it to

        bsg_job->request->msgcode == FC_BSG_RPT_ELS

instead.

Change the == to a != to avoid leaking the fcport structure or freeing
unallocated memory.

Fixes: 8c0eb596baa5 ("[SCSI] qla2xxx: Fix a memory leak in an error path of qla2x00_process_els()")
Signed-off-by: Joy Gu <jgu@purestorage.com>
---
 drivers/scsi/qla2xxx/qla_bsg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bart Van Assche Oct. 12, 2021, 8:29 p.m. UTC | #1
On 10/12/21 12:18 PM, Joy Gu wrote:
> Change the == to a != to avoid leaking the fcport structure or freeing
> unallocated memory.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index 4b5d28d89d69..655cf5de604b 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -431,7 +431,7 @@  qla2x00_process_els(struct bsg_job *bsg_job)
 	goto done_free_fcport;
 
 done_free_fcport:
-	if (bsg_request->msgcode == FC_BSG_RPT_ELS)
+	if (bsg_request->msgcode != FC_BSG_RPT_ELS)
 		qla2x00_free_fcport(fcport);
 done:
 	return rval;