Skip to contentSkip to conversation

scsi: qedf: Fix potential null pointer dereference

PATCH In review Liao Chen 2 participants 3 messages Sep 13, 2024 – Sep 19, 2024

Subsystems (2)
lore
Share & tools
lore

Liao Chen

author
#0 lore raw

PATCH 1/1 scsi: qedf: Fix potential null pointer dereference

qedf is checked to be null in this if branch, accessing its member will cause a null pointer dereference. Fix it by passing a direct NULL into the error function.

Fixes 51071f0831ea ("scsi: qedf: Don't process stag work during unload and recovery")
---
 drivers/scsi/qedf/qedf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qedf/qedf_main.c +1 -1
index 4813087e58a1..9d4738db0e51 100644
@@ -4021,7 +4021,7 @@ void qedf_stag_change_work(struct work_struct *work)
 	    container_of(work, struct qedf_ctx, stag_work.work);
 
 	if (!qedf) {
-		QEDF_ERR(&qedf->dbg_ctx, "qedf is NULL");
+		QEDF_ERR(NULL, "qedf is NULL");
 		return;
 	}
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 15 lines · Liao Chen

qedf is checked to be null in this if branch, accessing its member will cause a null pointer dereference. Fix it by passing a direct NULL into the error function.

Fixes 51071f0831ea ("scsi: qedf: Don't process stag work during unload and recovery")
---
  drivers/scsi/qedf/qedf_main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qedf/qedf_main.c +0 -0
index 4813087e58a1..9d4738db0e51 100644

drivers/scsi/qedf/qedf_main.c void qedf_stag_change_work(struct work_struct *work) · line 4027

Quoted 8 lines
drivers/scsi/qedf/qedf_main.c +1 -1
@@ -4021,7 +4021,7 @@ void qedf_stag_change_work(struct work_struct *work)
  	    container_of(work, struct qedf_ctx, stag_work.work);
 
  	if (!qedf) {
-		QEDF_ERR(&qedf->dbg_ctx, "qedf is NULL");
+		QEDF_ERR(NULL, "qedf is NULL");
  		return;
  	}
 

gentle ping

Thanks,
Chen

#2 lore raw
In reply to Liao Chen
Quoted 15 lines · Liao Chen

qedf is checked to be null in this if branch, accessing its member will cause a null pointer dereference. Fix it by passing a direct NULL into the error function.

Fixes 51071f0831ea ("scsi: qedf: Don't process stag work during unload and recovery")
---
  drivers/scsi/qedf/qedf_main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qedf/qedf_main.c +0 -0
index 4813087e58a1..9d4738db0e51 100644

drivers/scsi/qedf/qedf_main.c void qedf_stag_change_work(struct work_struct *work) · line 4026

Quoted 7 lines
drivers/scsi/qedf/qedf_main.c +1 -1
@@ -4021,7 +4021,7 @@ void qedf_stag_change_work(struct work_struct *work)
  	    container_of(work, struct qedf_ctx, stag_work.work);
 
  	if (!qedf) {
-		QEDF_ERR(&qedf->dbg_ctx, "qedf is NULL");
+		QEDF_ERR(NULL, "qedf is NULL");
  		return;
  	}

I think it would be better to remove the if-statement and the if-statement body since qedf cannot be NULL in this function.

Thanks,

Bart.