]> git.karo-electronics.de Git - linux-beck.git/commitdiff
lpfc: Fix crash in vport_delete.
authorJames Smart <james.smart@avagotech.com>
Thu, 21 May 2015 17:55:26 +0000 (13:55 -0400)
committerJames Bottomley <JBottomley@Odin.com>
Sat, 6 Jun 2015 05:39:07 +0000 (22:39 -0700)
We inadvertantly took the path to recreate the vport while in a
driver teardown path

Signed-off-by: Dick Kennedy <dick.kennedy@avagotech.com>
Signed-off-by: James Smart <james.smart@avagotech.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: James Bottomley <JBottomley@Odin.com>
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_nportdisc.c
drivers/scsi/lpfc/lpfc_vport.c

index 6ab831243d43e16b04813bef1cdaa10da8a02b71..14424e66b5615b7a7ac0d149239f176bcbcb6392 100644 (file)
@@ -4483,7 +4483,13 @@ lpfc_sli4_async_fip_evt(struct lpfc_hba *phba,
                        lpfc_destroy_vport_work_array(phba, vports);
                }
 
-               if (active_vlink_present) {
+               /*
+                * Don't re-instantiate if vport is marked for deletion.
+                * If we are here first then vport_delete is going to wait
+                * for discovery to complete.
+                */
+               if (!(vport->load_flag & FC_UNLOADING) &&
+                                       active_vlink_present) {
                        /*
                         * If there are other active VLinks present,
                         * re-instantiate the Vlink using FDISC.
index 4cb9882af15723aca8cbb34d611a722400c40935..09de6408c457157eb1b28bae7892637d37716794 100644 (file)
@@ -661,7 +661,13 @@ lpfc_rcv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
                        lpfc_destroy_vport_work_array(phba, vports);
                }
 
-               if (active_vlink_present) {
+               /*
+                * Don't re-instantiate if vport is marked for deletion.
+                * If we are here first then vport_delete is going to wait
+                * for discovery to complete.
+                */
+               if (!(vport->load_flag & FC_UNLOADING) &&
+                                       active_vlink_present) {
                        /*
                         * If there are other active VLinks present,
                         * re-instantiate the Vlink using FDISC.
index a87ee33f4f2a6619b9b2f92a35c6e571a7a8d37e..769012663a8f53c2590234009fec7d7127e15f85 100644 (file)
@@ -567,8 +567,8 @@ int
 lpfc_vport_delete(struct fc_vport *fc_vport)
 {
        struct lpfc_nodelist *ndlp = NULL;
-       struct Scsi_Host *shost = (struct Scsi_Host *) fc_vport->shost;
        struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data;
+       struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
        struct lpfc_hba   *phba = vport->phba;
        long timeout;
        bool ns_ndlp_referenced = false;
@@ -645,8 +645,8 @@ lpfc_vport_delete(struct fc_vport *fc_vport)
        }
 
        /* Remove FC host and then SCSI host with the vport */
-       fc_remove_host(lpfc_shost_from_vport(vport));
-       scsi_remove_host(lpfc_shost_from_vport(vport));
+       fc_remove_host(shost);
+       scsi_remove_host(shost);
 
        ndlp = lpfc_findnode_did(phba->pport, Fabric_DID);
 
@@ -772,7 +772,8 @@ skip_logo:
                 * Completion of unreg_vpi (lpfc_mbx_cmpl_unreg_vpi)
                 * does the scsi_host_put() to release the vport.
                 */
-               if (lpfc_mbx_unreg_vpi(vport))
+               if (!(vport->vpi_state & LPFC_VPI_REGISTERED) ||
+                               lpfc_mbx_unreg_vpi(vport))
                        scsi_host_put(shost);
        } else
                scsi_host_put(shost);