diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2012-12-21 22:40:28 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2013-01-28 23:06:19 -0500 |
commit | 33c7da0590d4e9e7420f8cf50722c4fe6932218f (patch) | |
tree | 5d93a95224b0cf72e245ff897ef3ecd96428ddb4 /drivers/scsi/bnx2fc | |
parent | 0225fea06ed2baa3d1bad0282c5feabe70eb1d21 (diff) |
[SCSI] bnx2fc: Remove potential NULL dereference
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>
Signed-off-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/bnx2fc')
-rw-r--r-- | drivers/scsi/bnx2fc/bnx2fc_io.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index 8d4626c07a12..c661ccd3d496 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c | |||
@@ -685,8 +685,8 @@ int bnx2fc_init_mp_req(struct bnx2fc_cmd *io_req) | |||
685 | static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) | 685 | static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) |
686 | { | 686 | { |
687 | struct fc_lport *lport; | 687 | struct fc_lport *lport; |
688 | struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); | 688 | struct fc_rport *rport; |
689 | struct fc_rport_libfc_priv *rp = rport->dd_data; | 689 | struct fc_rport_libfc_priv *rp; |
690 | struct fcoe_port *port; | 690 | struct fcoe_port *port; |
691 | struct bnx2fc_interface *interface; | 691 | struct bnx2fc_interface *interface; |
692 | struct bnx2fc_rport *tgt; | 692 | struct bnx2fc_rport *tgt; |
@@ -704,6 +704,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) | |||
704 | unsigned long start = jiffies; | 704 | unsigned long start = jiffies; |
705 | 705 | ||
706 | lport = shost_priv(host); | 706 | lport = shost_priv(host); |
707 | rport = starget_to_rport(scsi_target(sc_cmd->device)); | ||
707 | port = lport_priv(lport); | 708 | port = lport_priv(lport); |
708 | interface = port->priv; | 709 | interface = port->priv; |
709 | 710 | ||
@@ -712,6 +713,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) | |||
712 | rc = FAILED; | 713 | rc = FAILED; |
713 | goto tmf_err; | 714 | goto tmf_err; |
714 | } | 715 | } |
716 | rp = rport->dd_data; | ||
715 | 717 | ||
716 | rc = fc_block_scsi_eh(sc_cmd); | 718 | rc = fc_block_scsi_eh(sc_cmd); |
717 | if (rc) | 719 | if (rc) |