From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Bhanu Prakash Gollapudi" Date: Fri, 07 Sep 2012 18:23:59 +0000 Subject: Re: [PATCH 2/5] drivers/scsi/bnx2fc/bnx2fc_io.c: Remove potential NULL dereference Message-Id: <504A3BBF.5030604@broadcom.com> List-Id: References: <1344959388-19719-1-git-send-email-Julia.Lawall@lip6.fr> <1344959388-19719-3-git-send-email-Julia.Lawall@lip6.fr> In-Reply-To: <1344959388-19719-3-git-send-email-Julia.Lawall@lip6.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Julia Lawall Cc: kernel-janitors@vger.kernel.org, "James E.J. Bottomley" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org On 8/14/2012 8:49 AM, Julia Lawall wrote: > From: Julia Lawall > > 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/) > > // > @@ > 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; > // > > Signed-off-by: Julia Lawall > > --- > 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