Skip to contentSkip to conversation

bnx2fc: fix NULL checking in bnx2fc_initiate_tmf()

PATCH In review Xi Wang 2 participants 2 messages Nov 5, 2012

Subsystems (2)
lore
Share & tools
lore

Xi Wang

author
#0 lore raw

PATCH 1/1 bnx2fc: fix NULL checking in bnx2fc_initiate_tmf()

The dereference rport->data should come after the NULL check of rport.

---
 drivers/scsi/bnx2fc/bnx2fc_io.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/bnx2fc/bnx2fc_io.c +2 -1
index 8d4626c..eebe93c 100644
@@ -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)
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 21 lines · Xi Wang

The dereference rport->data should come after the NULL check of rport.

---
  drivers/scsi/bnx2fc/bnx2fc_io.c |    3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/bnx2fc/bnx2fc_io.c +1 -1
index 8d4626c..eebe93c 100644
@@ -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;

drivers/scsi/bnx2fc/bnx2fc_io.c static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) · line 718

Quoted 7 lines
drivers/scsi/bnx2fc/bnx2fc_io.c +1 -0
@@ -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)

I thought I acked similar patch sometime back, but this did not make it to the tree yet.

doing it again. Thanks!