Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33c7da05 authored by Julia Lawall's avatar Julia Lawall Committed by James Bottomley
Browse files

[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: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarBhanu Prakash Gollapudi <bprakash@broadcom.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent 0225fea0
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -685,8 +685,8 @@ int bnx2fc_init_mp_req(struct bnx2fc_cmd *io_req)
static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
{
{
	struct fc_lport *lport;
	struct fc_lport *lport;
	struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
	struct fc_rport *rport;
	struct fc_rport_libfc_priv *rp = rport->dd_data;
	struct fc_rport_libfc_priv *rp;
	struct fcoe_port *port;
	struct fcoe_port *port;
	struct bnx2fc_interface *interface;
	struct bnx2fc_interface *interface;
	struct bnx2fc_rport *tgt;
	struct bnx2fc_rport *tgt;
@@ -704,6 +704,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
	unsigned long start = jiffies;
	unsigned long start = jiffies;


	lport = shost_priv(host);
	lport = shost_priv(host);
	rport = starget_to_rport(scsi_target(sc_cmd->device));
	port = lport_priv(lport);
	port = lport_priv(lport);
	interface = port->priv;
	interface = port->priv;


@@ -712,6 +713,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
		rc = FAILED;
		rc = FAILED;
		goto tmf_err;
		goto tmf_err;
	}
	}
	rp = rport->dd_data;


	rc = fc_block_scsi_eh(sc_cmd);
	rc = fc_block_scsi_eh(sc_cmd);
	if (rc)
	if (rc)