Skip to contentSkip to conversation

scsi: qla4xxx: Prevent a potential error pointer dereference

PATCH Applied Dan Carpenter 3 participants 3 messages Aug 13, 2025 – Aug 15, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: qla4xxx: Prevent a potential error pointer dereference

The qla4xxx_get_ep_fwdb() function is supposed to return NULL on error, but qla4xxx_ep_connect() returns error pointers. Propagating the error pointers will lead to an Oops in the caller, so change the error pointers to NULL.

Fixes 13483730a13b ("[SCSI] qla4xxx: fix flash/ddb support")
---
 drivers/scsi/qla4xxx/ql4_os.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/scsi/qla4xxx/ql4_os.c +2 -0
index a39f1da4ce47..a761c0aa5127 100644
@@ -6606,6 +6606,8 @@ static struct iscsi_endpoint *qla4xxx_get_ep_fwdb(struct scsi_qla_host *ha,
 
 	ep = qla4xxx_ep_connect(ha->host, (struct sockaddr *)dst_addr, 0);
 	vfree(dst_addr);
+	if (IS_ERR(ep))
+		return NULL;
 	return ep;
 }
 
Signature · 1 line
2.47.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Dan Carpenter

The qla4xxx_get_ep_fwdb() function is supposed to return NULL on error, but qla4xxx_ep_connect() returns error pointers. Propagating the error pointers will lead to an Oops in the caller, so change the error pointers to NULL.

Looks right to me.

Quoted 22 lines
Fixes 13483730a13b ("[SCSI] qla4xxx: fix flash/ddb support")
---
 drivers/scsi/qla4xxx/ql4_os.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/scsi/qla4xxx/ql4_os.c +2 -0
index a39f1da4ce47..a761c0aa5127 100644
@@ -6606,6 +6606,8 @@ static struct iscsi_endpoint *qla4xxx_get_ep_fwdb(struct scsi_qla_host *ha,
 
 	ep = qla4xxx_ep_connect(ha->host, (struct sockaddr *)dst_addr, 0);
 	vfree(dst_addr);
+	if (IS_ERR(ep))
+		return NULL;
 	return ep;
 }
 
Signature · 1 line
2.47.2
#2 lore raw
In reply to Dan Carpenter
Quoted 6 lines · Dan Carpenter

The qla4xxx_get_ep_fwdb() function is supposed to return NULL on error, but qla4xxx_ep_connect() returns error pointers. Propagating the error pointers will lead to an Oops in the caller, so change the error pointers to NULL.

Applied to 6.17/scsi-fixes, thanks!

[1/1] scsi: qla4xxx: Prevent a potential error pointer dereference

      https://git.kernel.org/mkp/scsi/c/9dcf111dd3e7
Signature · 1 line
Martin K. Petersen