scsi: qedf: fixup locking in qedf_restart_rport()
authorHannes Reinecke <hare@suse.com>
Tue, 26 Mar 2019 07:38:44 +0000 (00:38 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 28 Mar 2019 01:54:52 +0000 (21:54 -0400)
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>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/qedf/qedf_els.c

index ac2bfc26bcdbc300606938496521f156266d4897..aad1f7c464fd1c3960a931b0908d3afae358c815 100644 (file)
@@ -380,10 +380,16 @@ void qedf_restart_rport(struct qedf_rport *fcport)
                QEDF_ERR(&(fcport->qedf->dbg_ctx),
                    "LOGO port_id=%x.\n", port_id);
                fc_rport_logoff(rdata);
+               mutex_lock(&lport->disc.disc_mutex);
                /* Recreate the rport and log back in */
                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);
 }