aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>2017-08-20 13:09:35 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2017-08-23 22:42:41 -0400
commit47c4ccd3086139d2085e0f1e59c0f26e8ce4ff46 (patch)
tree6ff8b2183a6ab609804bae7eb5c7f90cfc5faeb4
parentbd46fc406b30d1db1aff8dabaff8d18bb423fdcf (diff)
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: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Acked-by: Chad Dupuis <chad.dupuis@cavium.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/qedf/qedf_els.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c
index eb07f1de8afa..59c18ca4cda9 100644
--- a/drivers/scsi/qedf/qedf_els.c
+++ b/drivers/scsi/qedf/qedf_els.c
@@ -489,7 +489,7 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg)
489 489
490 /* If a SRR times out, simply free resources */ 490 /* If a SRR times out, simply free resources */
491 if (srr_req->event == QEDF_IOREQ_EV_ELS_TMO) 491 if (srr_req->event == QEDF_IOREQ_EV_ELS_TMO)
492 goto out_free; 492 goto out_put;
493 493
494 /* Normalize response data into struct fc_frame */ 494 /* Normalize response data into struct fc_frame */
495 mp_req = &(srr_req->mp_req); 495 mp_req = &(srr_req->mp_req);
@@ -501,7 +501,7 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg)
501 if (!fp) { 501 if (!fp) {
502 QEDF_ERR(&(qedf->dbg_ctx), 502 QEDF_ERR(&(qedf->dbg_ctx),
503 "fc_frame_alloc failure.\n"); 503 "fc_frame_alloc failure.\n");
504 goto out_free; 504 goto out_put;
505 } 505 }
506 506
507 /* Copy frame header from firmware into fp */ 507 /* Copy frame header from firmware into fp */
@@ -526,9 +526,10 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg)
526 } 526 }
527 527
528 fc_frame_free(fp); 528 fc_frame_free(fp);
529out_free: 529out_put:
530 /* Put reference for original command since SRR completed */ 530 /* Put reference for original command since SRR completed */
531 kref_put(&orig_io_req->refcount, qedf_release_cmd); 531 kref_put(&orig_io_req->refcount, qedf_release_cmd);
532out_free:
532 kfree(cb_arg); 533 kfree(cb_arg);
533} 534}
534 535
@@ -780,7 +781,7 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
780 781
781 /* If a REC times out, free resources */ 782 /* If a REC times out, free resources */
782 if (rec_req->event == QEDF_IOREQ_EV_ELS_TMO) 783 if (rec_req->event == QEDF_IOREQ_EV_ELS_TMO)
783 goto out_free; 784 goto out_put;
784 785
785 /* Normalize response data into struct fc_frame */ 786 /* Normalize response data into struct fc_frame */
786 mp_req = &(rec_req->mp_req); 787 mp_req = &(rec_req->mp_req);
@@ -792,7 +793,7 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
792 if (!fp) { 793 if (!fp) {
793 QEDF_ERR(&(qedf->dbg_ctx), 794 QEDF_ERR(&(qedf->dbg_ctx),
794 "fc_frame_alloc failure.\n"); 795 "fc_frame_alloc failure.\n");
795 goto out_free; 796 goto out_put;
796 } 797 }
797 798
798 /* Copy frame header from firmware into fp */ 799 /* Copy frame header from firmware into fp */
@@ -884,9 +885,10 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
884 885
885out_free_frame: 886out_free_frame:
886 fc_frame_free(fp); 887 fc_frame_free(fp);
887out_free: 888out_put:
888 /* Put reference for original command since REC completed */ 889 /* Put reference for original command since REC completed */
889 kref_put(&orig_io_req->refcount, qedf_release_cmd); 890 kref_put(&orig_io_req->refcount, qedf_release_cmd);
891out_free:
890 kfree(cb_arg); 892 kfree(cb_arg);
891} 893}
892 894