diff mbox series

[07/11] qla2xxx: Fix double free of the ha->vp_map pointer.

Message ID 20240223074514.8472-8-njavali@marvell.com
State Superseded
Headers show
Series qla2xxx misc. bug fixes | expand

Commit Message

Nilesh Javali Feb. 23, 2024, 7:45 a.m. UTC
From: Saurav Kashyap <skashyap@marvell.com>

Coverity scan reported potential risk of double free
of the pointer ha->vp_map.
ha→vp_map was freed in qla2x00_mem_alloc(), and again
freed in function qla2x00_mem_free(ha).

Assign NULL to vp_map and kfree take care of NULL.

Cc: stable@vger.kernel.org
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
---
 drivers/scsi/qla2xxx/qla_os.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index b3bb974ae797..1e2f52210f60 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -4602,6 +4602,7 @@  qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
 	ha->init_cb_dma = 0;
 fail_free_vp_map:
 	kfree(ha->vp_map);
+	ha->vp_map = NULL;
 fail:
 	ql_log(ql_log_fatal, NULL, 0x0030,
 	    "Memory allocation failure.\n");