All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chad Dupuis <chad.dupuis@cavium.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: QLogic-Storage-Upstream@cavium.com, jejb@linux.vnet.ibm.com,
	martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] scsi: qedf: Fix a potential NULL pointer dereference
Date: Wed, 23 Aug 2017 15:49:34 +0000	[thread overview]
Message-ID: <alpine.OSX.2.00.1708231148580.1209@n6024mn55p0yw1.qlogic.org> (raw)
In-Reply-To: <20170820170935.14767-1-christophe.jaillet@wanadoo.fr>


On Sun, 20 Aug 2017, 1:09pm, Christophe JAILLET wrote:

> 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 additionnal label in the error handling path in order
> to avoid this NULL pointer dereference.
> 
> Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/scsi/qedf/qedf_els.c | 14 ++++++++------
>  1 file 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)
>  
>  	/* If a SRR times out, simply free resources */
>  	if (srr_req->event = QEDF_IOREQ_EV_ELS_TMO)
> -		goto out_free;
> +		goto out_put;
>  
>  	/* Normalize response data into struct fc_frame */
>  	mp_req = &(srr_req->mp_req);
> @@ -501,7 +501,7 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg)
>  	if (!fp) {
>  		QEDF_ERR(&(qedf->dbg_ctx),
>  		    "fc_frame_alloc failure.\n");
> -		goto out_free;
> +		goto out_put;
>  	}
>  
>  	/* Copy frame header from firmware into fp */
> @@ -526,9 +526,10 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg)
>  	}
>  
>  	fc_frame_free(fp);
> -out_free:
> +out_put:
>  	/* Put reference for original command since SRR completed */
>  	kref_put(&orig_io_req->refcount, qedf_release_cmd);
> +out_free:
>  	kfree(cb_arg);
>  }
>  
> @@ -780,7 +781,7 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
>  
>  	/* If a REC times out, free resources */
>  	if (rec_req->event = QEDF_IOREQ_EV_ELS_TMO)
> -		goto out_free;
> +		goto out_put;
>  
>  	/* Normalize response data into struct fc_frame */
>  	mp_req = &(rec_req->mp_req);
> @@ -792,7 +793,7 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
>  	if (!fp) {
>  		QEDF_ERR(&(qedf->dbg_ctx),
>  		    "fc_frame_alloc failure.\n");
> -		goto out_free;
> +		goto out_put;
>  	}
>  
>  	/* Copy frame header from firmware into fp */
> @@ -884,9 +885,10 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
>  
>  out_free_frame:
>  	fc_frame_free(fp);
> -out_free:
> +out_put:
>  	/* Put reference for original command since REC completed */
>  	kref_put(&orig_io_req->refcount, qedf_release_cmd);
> +out_free:
>  	kfree(cb_arg);
>  }
>  
> 

Thanks for the catch.

Acked-by: Chad Dupuis <chad.dupuis@cavium.com>

WARNING: multiple messages have this Message-ID (diff)
From: Chad Dupuis <chad.dupuis@cavium.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: QLogic-Storage-Upstream@cavium.com, jejb@linux.vnet.ibm.com,
	martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] scsi: qedf: Fix a potential NULL pointer dereference
Date: Wed, 23 Aug 2017 11:49:34 -0400 (EDT)	[thread overview]
Message-ID: <alpine.OSX.2.00.1708231148580.1209@n6024mn55p0yw1.qlogic.org> (raw)
In-Reply-To: <20170820170935.14767-1-christophe.jaillet@wanadoo.fr>


On Sun, 20 Aug 2017, 1:09pm, Christophe JAILLET wrote:

> 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 additionnal label in the error handling path in order
> to avoid this NULL pointer dereference.
> 
> Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/scsi/qedf/qedf_els.c | 14 ++++++++------
>  1 file 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)
>  
>  	/* If a SRR times out, simply free resources */
>  	if (srr_req->event == QEDF_IOREQ_EV_ELS_TMO)
> -		goto out_free;
> +		goto out_put;
>  
>  	/* Normalize response data into struct fc_frame */
>  	mp_req = &(srr_req->mp_req);
> @@ -501,7 +501,7 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg)
>  	if (!fp) {
>  		QEDF_ERR(&(qedf->dbg_ctx),
>  		    "fc_frame_alloc failure.\n");
> -		goto out_free;
> +		goto out_put;
>  	}
>  
>  	/* Copy frame header from firmware into fp */
> @@ -526,9 +526,10 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg)
>  	}
>  
>  	fc_frame_free(fp);
> -out_free:
> +out_put:
>  	/* Put reference for original command since SRR completed */
>  	kref_put(&orig_io_req->refcount, qedf_release_cmd);
> +out_free:
>  	kfree(cb_arg);
>  }
>  
> @@ -780,7 +781,7 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
>  
>  	/* If a REC times out, free resources */
>  	if (rec_req->event == QEDF_IOREQ_EV_ELS_TMO)
> -		goto out_free;
> +		goto out_put;
>  
>  	/* Normalize response data into struct fc_frame */
>  	mp_req = &(rec_req->mp_req);
> @@ -792,7 +793,7 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
>  	if (!fp) {
>  		QEDF_ERR(&(qedf->dbg_ctx),
>  		    "fc_frame_alloc failure.\n");
> -		goto out_free;
> +		goto out_put;
>  	}
>  
>  	/* Copy frame header from firmware into fp */
> @@ -884,9 +885,10 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
>  
>  out_free_frame:
>  	fc_frame_free(fp);
> -out_free:
> +out_put:
>  	/* Put reference for original command since REC completed */
>  	kref_put(&orig_io_req->refcount, qedf_release_cmd);
> +out_free:
>  	kfree(cb_arg);
>  }
>  
> 

Thanks for the catch.

Acked-by: Chad Dupuis <chad.dupuis@cavium.com>

  reply	other threads:[~2017-08-23 15:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-20 17:09 [PATCH] scsi: qedf: Fix a potential NULL pointer dereference Christophe JAILLET
2017-08-20 17:09 ` Christophe JAILLET
2017-08-23 15:49 ` Chad Dupuis [this message]
2017-08-23 15:49   ` Chad Dupuis
2017-08-24  2:43 ` Martin K. Petersen
2017-08-24  2:43   ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.OSX.2.00.1708231148580.1209@n6024mn55p0yw1.qlogic.org \
    --to=chad.dupuis@cavium.com \
    --cc=QLogic-Storage-Upstream@cavium.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.