diff mbox series

[2/5] qedf: fixup locking in qedf_restart_rport()

Message ID 20180905135347.138195-3-hare@suse.de (mailing list archive)
State Changes Requested
Headers show
Series qedf: fixup NULL pointer reference in fc_lookup_rport() | expand

Commit Message

Hannes Reinecke Sept. 5, 2018, 1:53 p.m. UTC
fc_rport_create() needs to be called with disc_mutex held.
And we should re-assign the 'rdata' pointer in case it got changed.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/qedf/qedf_els.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c
index acb8157a96a8..f93379a4510c 100644
--- a/drivers/scsi/qedf/qedf_els.c
+++ b/drivers/scsi/qedf/qedf_els.c
@@ -363,9 +363,14 @@  void qedf_restart_rport(struct qedf_rport *fcport)
 		    "LOGO port_id=%x.\n", port_id);
 		fc_rport_logoff(rdata);
 		/* Recreate the rport and log back in */
+		mutex_lock(&lport->disc.disc_mutex);
 		rdata = fc_rport_create(lport, port_id);
-		if (rdata)
+		if (rdata) {
+			mutex_unlock(&lport->disc.disc_mutex);
 			fc_rport_login(rdata);
+			fcport->rdata = rdata;
+		} else
+			mutex_unlock(&lport->disc.disc_mutex);
 	}
 	clear_bit(QEDF_RPORT_IN_RESET, &fcport->flags);
 }