[SCSI] libsas: fix panic when single phy is disabled on a wide port
[pandora-kernel.git] / drivers / scsi / libsas / sas_expander.c
index c9e3dc0..16ad97d 100644 (file)
@@ -1769,10 +1769,12 @@ static void sas_unregister_devs_sas_addr(struct domain_device *parent,
                sas_disable_routing(parent, phy->attached_sas_addr);
        }
        memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE);
-       sas_port_delete_phy(phy->port, phy->phy);
-       if (phy->port->num_phys == 0)
-               sas_port_delete(phy->port);
-       phy->port = NULL;
+       if (phy->port) {
+               sas_port_delete_phy(phy->port, phy->phy);
+               if (phy->port->num_phys == 0)
+                       sas_port_delete(phy->port);
+               phy->port = NULL;
+       }
 }
 
 static int sas_discover_bfs_by_root_level(struct domain_device *root,