scsi: qedf: Fix potential null pointer dereference
Subsystems (2)
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. As suggested by Bart, fix it by deleting the logic since qedf cannot be NULL in this function.
--- drivers/scsi/qedf/qedf_main.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/scsi/qedf/qedf_main.c +0 -5
@@ -4018,11 +4018,6 @@ void qedf_stag_change_work(struct work_struct *work)struct qedf_ctx *qedf = container_of(work, struct qedf_ctx, stag_work.work); -if (!qedf) { -QEDF_ERR (&qedf->dbg_ctx,"qedf is NULL" ); -return ; - } -if (test_bit (QEDF_IN_RECOVERY , &qedf->flags)) {QEDF_ERR (&qedf->dbg_ctx,"Already is in recovery, hence not calling software context reset.\n" );
Signature · 1 line
2.34.1
Quoted 15 lines · Liao Chen
qedf is checked to be null in this if branch, accessing its member will cause a null pointer dereference. As suggested by Bart, fix it by deleting the logic since qedf cannot be NULL in this function.
Signed-off-by Liao Chen <[email protected]>--- drivers/scsi/qedf/qedf_main.c | 5 ----- 1 file changed, 5 deletions(-)drivers/scsi/qedf/qedf_main.c +0
-0@@ -4018,11 +4018,6 @@ void qedf_stag_change_work(struct work_struct *work) struct qedf_ctx *qedf =
drivers/scsi/qedf/qedf_main.c void qedf_stag_change_work(struct work_struct *work) · line 4023
Quoted 10 lines
drivers/scsi/qedf/qedf_main.c +0
-5container_of(work, struct qedf_ctx, stag_work.work); -if (!qedf) { -QEDF_ERR (&qedf->dbg_ctx,"qedf is NULL" ); -return ; - } -if (test_bit (QEDF_IN_RECOVERY , &qedf->flags)) {QEDF_ERR (&qedf->dbg_ctx,"Already is in recovery, hence not calling software context reset.\n" );
The patch looks good to me but the patch description could be more clear and the subject is wrong. How about this?
[PATCH] scsi: qedf: Remove dead code
If container_of() is used correctly, its result is never NULL. Remove the code that depends on container_of() returning a NULL pointer.