Print this page
XXXX cpudrv attach is racy

@@ -275,12 +275,20 @@
                         ddi_soft_state_free(cpudrv_state, instance);
                         cpudrv_enabled = B_FALSE;
                         return (DDI_FAILURE);
                 }
 
+                if (!cpudrv_is_enabled(cpudsp)) {
+                        cmn_err(CE_WARN, "cpudrv_attach: instance %d: "
+                            "not supported or it got disabled on us",
+                            instance);
+                        cpudrv_enabled = B_FALSE;
+                        ddi_soft_state_free(cpudrv_state, instance);
+                        return (DDI_FAILURE);
+                }
+
                 mutex_init(&cpudsp->lock, NULL, MUTEX_DRIVER, NULL);
-                if (cpudrv_is_enabled(cpudsp)) {
                         if (cpudrv_init(cpudsp) != DDI_SUCCESS) {
                                 cpudrv_enabled = B_FALSE;
                                 cpudrv_free(cpudsp);
                                 ddi_soft_state_free(cpudrv_state, instance);
                                 return (DDI_FAILURE);

@@ -334,12 +342,10 @@
                          * has been initialized.
                          */
                         CPUDRV_MONITOR_INIT(cpudsp);
                         mutex_exit(&cpudsp->lock);
 
-                }
-
                 if (!cpudrv_mach_init(cpudsp)) {
                         cmn_err(CE_WARN, "cpudrv_attach: instance %d: "
                             "cpudrv_mach_init failed", instance);
                         cpudrv_enabled = B_FALSE;
                         cpudrv_free(cpudsp);