Skip to content

Commit 47c4ccd

Browse files
tititiou36martinkpetersen
authored andcommitted
scsi: qedf: Fix a potential NULL pointer dereference
At the beginning of 'qedf_srr_compl()' and of 'qedf_rec_compl()', we check if 'orig_io_req' is NULL. If this happens, a NULL pointer dereference will occur in the error handling path. Fix it by adding an additional label in the error handling path in order to avoid this NULL pointer dereference. [mkp: typo] Fixes: 61d8658 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.") Signed-off-by: Christophe JAILLET <[email protected]> Acked-by: Chad Dupuis <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent bd46fc4 commit 47c4ccd

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/scsi/qedf/qedf_els.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg)
489489

490490
/* If a SRR times out, simply free resources */
491491
if (srr_req->event == QEDF_IOREQ_EV_ELS_TMO)
492-
goto out_free;
492+
goto out_put;
493493

494494
/* Normalize response data into struct fc_frame */
495495
mp_req = &(srr_req->mp_req);
@@ -501,7 +501,7 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg)
501501
if (!fp) {
502502
QEDF_ERR(&(qedf->dbg_ctx),
503503
"fc_frame_alloc failure.\n");
504-
goto out_free;
504+
goto out_put;
505505
}
506506

507507
/* Copy frame header from firmware into fp */
@@ -526,9 +526,10 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg)
526526
}
527527

528528
fc_frame_free(fp);
529-
out_free:
529+
out_put:
530530
/* Put reference for original command since SRR completed */
531531
kref_put(&orig_io_req->refcount, qedf_release_cmd);
532+
out_free:
532533
kfree(cb_arg);
533534
}
534535

@@ -780,7 +781,7 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
780781

781782
/* If a REC times out, free resources */
782783
if (rec_req->event == QEDF_IOREQ_EV_ELS_TMO)
783-
goto out_free;
784+
goto out_put;
784785

785786
/* Normalize response data into struct fc_frame */
786787
mp_req = &(rec_req->mp_req);
@@ -792,7 +793,7 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
792793
if (!fp) {
793794
QEDF_ERR(&(qedf->dbg_ctx),
794795
"fc_frame_alloc failure.\n");
795-
goto out_free;
796+
goto out_put;
796797
}
797798

798799
/* Copy frame header from firmware into fp */
@@ -884,9 +885,10 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
884885

885886
out_free_frame:
886887
fc_frame_free(fp);
887-
out_free:
888+
out_put:
888889
/* Put reference for original command since REC completed */
889890
kref_put(&orig_io_req->refcount, qedf_release_cmd);
891+
out_free:
890892
kfree(cb_arg);
891893
}
892894

0 commit comments

Comments
 (0)