All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bhanu Prakash Gollapudi" <bprakash@broadcom.com>
To: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: kernel-janitors@vger.kernel.org,
	"James E.J. Bottomley" <JBottomley@parallels.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] drivers/scsi/bnx2fc/bnx2fc_io.c: Remove potential NULL dereference
Date: Fri, 07 Sep 2012 18:23:59 +0000	[thread overview]
Message-ID: <504A3BBF.5030604@broadcom.com> (raw)
In-Reply-To: <1344959388-19719-3-git-send-email-Julia.Lawall@lip6.fr>

On 8/14/2012 8:49 AM, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> If the NULL test is necessary, the initialization involving a dereference of
> the tested value should be moved after the NULL test.
>
> The sematic patch that fixes this problem is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> type T;
> expression E;
> identifier i,fld;
> statement S;
> @@
>
> - T i = E->fld;
> + T i;
>    ... when != E
>        when != i
>    if (E = NULL) S
> + i = E->fld;
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
>   drivers/scsi/bnx2fc/bnx2fc_io.c |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
> index 73f231c..1dd82db 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_io.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
> @@ -686,7 +686,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
>   {
>   	struct fc_lport *lport;
>   	struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
> -	struct fc_rport_libfc_priv *rp = rport->dd_data;
> +	struct fc_rport_libfc_priv *rp;
>   	struct fcoe_port *port;
>   	struct bnx2fc_interface *interface;
>   	struct bnx2fc_rport *tgt;
> @@ -712,6 +712,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
>   		rc = FAILED;
>   		goto tmf_err;
>   	}
> +	rp = rport->dd_data;
>
>   	rc = fc_block_scsi_eh(sc_cmd);
>   	if (rc)
>
>
Thanks Julia.

Acked-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com>



WARNING: multiple messages have this Message-ID (diff)
From: "Bhanu Prakash Gollapudi" <bprakash@broadcom.com>
To: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: kernel-janitors@vger.kernel.org,
	"James E.J. Bottomley" <JBottomley@parallels.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] drivers/scsi/bnx2fc/bnx2fc_io.c: Remove potential NULL dereference
Date: Fri, 7 Sep 2012 11:23:59 -0700	[thread overview]
Message-ID: <504A3BBF.5030604@broadcom.com> (raw)
In-Reply-To: <1344959388-19719-3-git-send-email-Julia.Lawall@lip6.fr>

On 8/14/2012 8:49 AM, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> If the NULL test is necessary, the initialization involving a dereference of
> the tested value should be moved after the NULL test.
>
> The sematic patch that fixes this problem is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> type T;
> expression E;
> identifier i,fld;
> statement S;
> @@
>
> - T i = E->fld;
> + T i;
>    ... when != E
>        when != i
>    if (E == NULL) S
> + i = E->fld;
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
>   drivers/scsi/bnx2fc/bnx2fc_io.c |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
> index 73f231c..1dd82db 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_io.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
> @@ -686,7 +686,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
>   {
>   	struct fc_lport *lport;
>   	struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
> -	struct fc_rport_libfc_priv *rp = rport->dd_data;
> +	struct fc_rport_libfc_priv *rp;
>   	struct fcoe_port *port;
>   	struct bnx2fc_interface *interface;
>   	struct bnx2fc_rport *tgt;
> @@ -712,6 +712,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
>   		rc = FAILED;
>   		goto tmf_err;
>   	}
> +	rp = rport->dd_data;
>
>   	rc = fc_block_scsi_eh(sc_cmd);
>   	if (rc)
>
>
Thanks Julia.

Acked-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com>

  parent reply	other threads:[~2012-09-07 18:23 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-14 15:49 [PATCH 0/5] Remove potential NULL dereference Julia Lawall
2012-08-14 15:49 ` Julia Lawall
2012-08-14 15:49 ` [PATCH 1/5] drivers/block/swim3.c: " Julia Lawall
2012-08-14 15:49   ` Julia Lawall
2012-08-14 15:49 ` [PATCH 2/5] drivers/scsi/bnx2fc/bnx2fc_io.c: " Julia Lawall
2012-08-14 15:49   ` Julia Lawall
2012-08-15 14:33   ` walter harms
2012-08-15 14:43   ` Julia Lawall
2012-08-15 14:53   ` Julia Lawall
2012-08-15 15:29   ` walter harms
2012-09-07 18:23   ` Bhanu Prakash Gollapudi [this message]
2012-09-07 18:23     ` Bhanu Prakash Gollapudi
2012-09-24 19:37     ` Bhanu Prakash Gollapudi
2012-08-14 15:49 ` [PATCH 3/5] drivers/media/video/{s2255drv.c,tm6000/tm6000-alsa.c,tm6000/tm6000-input.c}: Remove pote Julia Lawall
2012-08-14 15:49   ` [PATCH 3/5] drivers/media/video/{s2255drv.c,tm6000/tm6000-alsa.c,tm6000/tm6000-input.c}: Remove potential NULL dereferences Julia Lawall
2012-08-14 15:49 ` [PATCH 4/5] drivers/net/ethernet/ti/davinci_cpdma.c: Remove potential NULL dereference Julia Lawall
2012-08-14 15:49   ` Julia Lawall
2012-08-15  0:00   ` David Miller
2012-08-15  0:00     ` David Miller
2012-08-14 15:49 ` [PATCH 5/5] arch/powerpc/platforms/powernv/pci.c: Remove potential NULL dereferences Julia Lawall
2012-08-14 15:49   ` Julia Lawall
2012-08-14 15:49   ` Julia Lawall

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=504A3BBF.5030604@broadcom.com \
    --to=bprakash@broadcom.com \
    --cc=JBottomley@parallels.com \
    --cc=Julia.Lawall@lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /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.