Print this page
4233 mptsas topo change buffer overflow


 854                 return (DDI_FAILURE);
 855         }
 856 
 857         if (ddi_prop_update_int(DDI_DEV_T_NONE, dip,
 858             "dynamic-port", dynamic_port) !=
 859             DDI_PROP_SUCCESS) {
 860                 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "dynamic-port");
 861                 mptsas_log(mpt, CE_WARN, "mptsas dynamic port "
 862                     "prop update failed");
 863                 return (DDI_FAILURE);
 864         }
 865         if (ddi_prop_update_int(DDI_DEV_T_NONE, dip,
 866             MPTSAS_VIRTUAL_PORT, 0) !=
 867             DDI_PROP_SUCCESS) {
 868                 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip,
 869                     MPTSAS_VIRTUAL_PORT);
 870                 mptsas_log(mpt, CE_WARN, "mptsas virtual port "
 871                     "prop update failed");
 872                 return (DDI_FAILURE);
 873         }
 874         mptsas_smhba_set_phy_props(mpt,
 875             iport, dip, numphys, &attached_devhdl);
 876 
 877         mutex_enter(&mpt->m_mutex);
 878         page_address = (MPI2_SAS_DEVICE_PGAD_FORM_HANDLE &
 879             MPI2_SAS_DEVICE_PGAD_FORM_MASK) | (uint32_t)attached_devhdl;
 880         rval = mptsas_get_sas_device_page0(mpt, page_address, &dev_hdl,
 881             &attached_sas_wwn, &dev_info, &phy_port, &phy_id,
 882             &pdev_hdl, &bay_num, &enclosure);
 883         if (rval != DDI_SUCCESS) {
 884                 mptsas_log(mpt, CE_WARN,
 885                     "Failed to get device page0 for handle:%d",
 886                     attached_devhdl);
 887                 mutex_exit(&mpt->m_mutex);
 888                 return (DDI_FAILURE);
 889         }
 890 
 891         for (i = 0; i < MPTSAS_MAX_PHYS; i++) {
 892                 bzero(phymask, sizeof (phymask));
 893                 (void) sprintf(phymask, "%x", mpt->m_phy_info[i].phy_mask);
 894                 if (strcmp(phymask, iport) == 0) {
 895                         (void) sprintf(&mpt->m_phy_info[i].smhba_info.path[0],


5936                                     MPTSAS_NUM_PHYS, 1) !=
5937                                     DDI_PROP_SUCCESS) {
5938                                         (void) ddi_prop_remove(DDI_DEV_T_NONE,
5939                                             parent, MPTSAS_NUM_PHYS);
5940                                         mptsas_log(mpt, CE_WARN, "Failed to"
5941                                             " create num-phys props");
5942                                         return;
5943                                 }
5944 
5945                                 /*
5946                                  * Update PHY info for smhba
5947                                  */
5948                                 mutex_enter(&mpt->m_mutex);
5949                                 if (mptsas_smhba_phy_init(mpt)) {
5950                                         mutex_exit(&mpt->m_mutex);
5951                                         mptsas_log(mpt, CE_WARN, "mptsas phy"
5952                                             " update failed");
5953                                         return;
5954                                 }
5955                                 mutex_exit(&mpt->m_mutex);
5956                                 mptsas_smhba_set_phy_props(mpt,
5957                                     ddi_get_name_addr(parent), parent,
5958                                     1, &attached_devhdl);





5959                                 if (ddi_prop_update_int(DDI_DEV_T_NONE, parent,
5960                                     MPTSAS_VIRTUAL_PORT, 0) !=
5961                                     DDI_PROP_SUCCESS) {
5962                                         (void) ddi_prop_remove(DDI_DEV_T_NONE,
5963                                             parent, MPTSAS_VIRTUAL_PORT);
5964                                         mptsas_log(mpt, CE_WARN,
5965                                             "mptsas virtual-port"
5966                                             "port prop update failed");
5967                                         return;
5968                                 }
5969                         }
5970                 }
5971                 mutex_enter(&mpt->m_mutex);
5972 
5973                 NDBG20(("mptsas%d handle_topo_change to online devhdl:%x, "
5974                     "phymask:%x.", mpt->m_instance, ptgt->m_devhdl,
5975                     ptgt->m_phymask));
5976                 break;
5977         }
5978         case MPTSAS_DR_EVENT_OFFLINE_TARGET:


14882                                 break;
14883                         }
14884                 }
14885 
14886                 for (i = 0; i < MPTSAS_MAX_PHYS; i++) {
14887                         if ((phy_mask >> i) & 0x01) {
14888                                 numphys++;
14889                         }
14890                 }
14891                 /*
14892                  * Update PHY info for smhba
14893                  */
14894                 if (mptsas_smhba_phy_init(mpt)) {
14895                         mutex_exit(&mpt->m_mutex);
14896                         mptsas_log(mpt, CE_WARN, "mptsas phy update "
14897                             "failed");
14898                         goto smp_create_done;
14899                 }
14900                 mutex_exit(&mpt->m_mutex);
14901 
14902                 mptsas_smhba_set_phy_props(mpt, iport, pdip,
14903                     numphys, &attached_devhdl);
14904 
14905                 if (ddi_prop_update_int(DDI_DEV_T_NONE, pdip,
14906                     MPTSAS_NUM_PHYS, numphys) !=
14907                     DDI_PROP_SUCCESS) {
14908                         (void) ddi_prop_remove(DDI_DEV_T_NONE, pdip,
14909                             MPTSAS_NUM_PHYS);
14910                         mptsas_log(mpt, CE_WARN, "mptsas update "
14911                             "num phys props failed");
14912                         goto smp_create_done;
14913                 }
14914                 /*
14915                  * Add parent's props for SMHBA support
14916                  */
14917                 if (ddi_prop_update_string(DDI_DEV_T_NONE, pdip,
14918                     SCSI_ADDR_PROP_ATTACHED_PORT, wwn_str) !=
14919                     DDI_PROP_SUCCESS) {
14920                         (void) ddi_prop_remove(DDI_DEV_T_NONE, pdip,
14921                             SCSI_ADDR_PROP_ATTACHED_PORT);
14922                         mptsas_log(mpt, CE_WARN, "mptsas update iport"
14923                             "attached-port failed");




 854                 return (DDI_FAILURE);
 855         }
 856 
 857         if (ddi_prop_update_int(DDI_DEV_T_NONE, dip,
 858             "dynamic-port", dynamic_port) !=
 859             DDI_PROP_SUCCESS) {
 860                 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "dynamic-port");
 861                 mptsas_log(mpt, CE_WARN, "mptsas dynamic port "
 862                     "prop update failed");
 863                 return (DDI_FAILURE);
 864         }
 865         if (ddi_prop_update_int(DDI_DEV_T_NONE, dip,
 866             MPTSAS_VIRTUAL_PORT, 0) !=
 867             DDI_PROP_SUCCESS) {
 868                 (void) ddi_prop_remove(DDI_DEV_T_NONE, dip,
 869                     MPTSAS_VIRTUAL_PORT);
 870                 mptsas_log(mpt, CE_WARN, "mptsas virtual port "
 871                     "prop update failed");
 872                 return (DDI_FAILURE);
 873         }
 874         mptsas_smhba_set_all_phy_props(mpt, dip, numphys, phy_mask,
 875             &attached_devhdl);
 876 
 877         mutex_enter(&mpt->m_mutex);
 878         page_address = (MPI2_SAS_DEVICE_PGAD_FORM_HANDLE &
 879             MPI2_SAS_DEVICE_PGAD_FORM_MASK) | (uint32_t)attached_devhdl;
 880         rval = mptsas_get_sas_device_page0(mpt, page_address, &dev_hdl,
 881             &attached_sas_wwn, &dev_info, &phy_port, &phy_id,
 882             &pdev_hdl, &bay_num, &enclosure);
 883         if (rval != DDI_SUCCESS) {
 884                 mptsas_log(mpt, CE_WARN,
 885                     "Failed to get device page0 for handle:%d",
 886                     attached_devhdl);
 887                 mutex_exit(&mpt->m_mutex);
 888                 return (DDI_FAILURE);
 889         }
 890 
 891         for (i = 0; i < MPTSAS_MAX_PHYS; i++) {
 892                 bzero(phymask, sizeof (phymask));
 893                 (void) sprintf(phymask, "%x", mpt->m_phy_info[i].phy_mask);
 894                 if (strcmp(phymask, iport) == 0) {
 895                         (void) sprintf(&mpt->m_phy_info[i].smhba_info.path[0],


5936                                     MPTSAS_NUM_PHYS, 1) !=
5937                                     DDI_PROP_SUCCESS) {
5938                                         (void) ddi_prop_remove(DDI_DEV_T_NONE,
5939                                             parent, MPTSAS_NUM_PHYS);
5940                                         mptsas_log(mpt, CE_WARN, "Failed to"
5941                                             " create num-phys props");
5942                                         return;
5943                                 }
5944 
5945                                 /*
5946                                  * Update PHY info for smhba
5947                                  */
5948                                 mutex_enter(&mpt->m_mutex);
5949                                 if (mptsas_smhba_phy_init(mpt)) {
5950                                         mutex_exit(&mpt->m_mutex);
5951                                         mptsas_log(mpt, CE_WARN, "mptsas phy"
5952                                             " update failed");
5953                                         return;
5954                                 }
5955                                 mutex_exit(&mpt->m_mutex);
5956 
5957                                 /*
5958                                  * topo_node->un.physport is really the PHY#
5959                                  * for direct attached devices
5960                                  */
5961                                 mptsas_smhba_set_one_phy_props(mpt, parent,
5962                                     topo_node->un.physport, &attached_devhdl);
5963 
5964                                 if (ddi_prop_update_int(DDI_DEV_T_NONE, parent,
5965                                     MPTSAS_VIRTUAL_PORT, 0) !=
5966                                     DDI_PROP_SUCCESS) {
5967                                         (void) ddi_prop_remove(DDI_DEV_T_NONE,
5968                                             parent, MPTSAS_VIRTUAL_PORT);
5969                                         mptsas_log(mpt, CE_WARN,
5970                                             "mptsas virtual-port"
5971                                             "port prop update failed");
5972                                         return;
5973                                 }
5974                         }
5975                 }
5976                 mutex_enter(&mpt->m_mutex);
5977 
5978                 NDBG20(("mptsas%d handle_topo_change to online devhdl:%x, "
5979                     "phymask:%x.", mpt->m_instance, ptgt->m_devhdl,
5980                     ptgt->m_phymask));
5981                 break;
5982         }
5983         case MPTSAS_DR_EVENT_OFFLINE_TARGET:


14887                                 break;
14888                         }
14889                 }
14890 
14891                 for (i = 0; i < MPTSAS_MAX_PHYS; i++) {
14892                         if ((phy_mask >> i) & 0x01) {
14893                                 numphys++;
14894                         }
14895                 }
14896                 /*
14897                  * Update PHY info for smhba
14898                  */
14899                 if (mptsas_smhba_phy_init(mpt)) {
14900                         mutex_exit(&mpt->m_mutex);
14901                         mptsas_log(mpt, CE_WARN, "mptsas phy update "
14902                             "failed");
14903                         goto smp_create_done;
14904                 }
14905                 mutex_exit(&mpt->m_mutex);
14906 
14907                 mptsas_smhba_set_all_phy_props(mpt, pdip, numphys, phy_mask,
14908                     &attached_devhdl);
14909 
14910                 if (ddi_prop_update_int(DDI_DEV_T_NONE, pdip,
14911                     MPTSAS_NUM_PHYS, numphys) !=
14912                     DDI_PROP_SUCCESS) {
14913                         (void) ddi_prop_remove(DDI_DEV_T_NONE, pdip,
14914                             MPTSAS_NUM_PHYS);
14915                         mptsas_log(mpt, CE_WARN, "mptsas update "
14916                             "num phys props failed");
14917                         goto smp_create_done;
14918                 }
14919                 /*
14920                  * Add parent's props for SMHBA support
14921                  */
14922                 if (ddi_prop_update_string(DDI_DEV_T_NONE, pdip,
14923                     SCSI_ADDR_PROP_ATTACHED_PORT, wwn_str) !=
14924                     DDI_PROP_SUCCESS) {
14925                         (void) ddi_prop_remove(DDI_DEV_T_NONE, pdip,
14926                             SCSI_ADDR_PROP_ATTACHED_PORT);
14927                         mptsas_log(mpt, CE_WARN, "mptsas update iport"
14928                             "attached-port failed");