Index: /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/DarwinKeyboard.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/DarwinKeyboard.cpp	(revision 49954)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/DarwinKeyboard.cpp	(revision 49955)
@@ -1281,4 +1281,9 @@
     IOReturn      rc = kIOReturnError;
 
+    /* Try to resume built-in keyboard. Abort if failed in order to avoid GUI freezes. */
+    int rc1 = SUPR3ResumeBuiltinKeyboard();
+    if (RT_FAILURE(rc1))
+        return rc1;
+
     valueRef = IOHIDValueCreateWithIntegerValue(kCFAllocatorDefault, element, 0, (fEnabled) ? 1 : 0);
     if (valueRef)
@@ -1302,4 +1307,9 @@
     IOReturn      rc;
     CFIndex       integerValue;
+
+    /* Try to resume built-in keyboard. Abort if failed in order to avoid GUI freezes. */
+    int rc1 = SUPR3ResumeBuiltinKeyboard();
+    if (RT_FAILURE(rc1))
+        return rc1;
 
     rc = IOHIDDeviceGetValue(hidDevice, element, &valueRef);
@@ -1332,9 +1342,4 @@
     int        rc2 = 0;
 
-    /* Try to resume built-in keyboard. Abort if failed in order to avoid GUI freezes. */
-    int rc1 = SUPR3ResumeBuiltinKeyboard();
-    if (RT_FAILURE(rc1))
-        return rc1;
-
     matchingElementsArrayRef = IOHIDDeviceCopyMatchingElements(hidDevice, elementMatchingDict, kIOHIDOptionsTypeNone);
     if (matchingElementsArrayRef)
@@ -1382,9 +1387,4 @@
     int        rc2 = 0;
 
-    /* Try to resume built-in keyboard. Abort if failed in order to avoid GUI freezes. */
-    int rc1 = SUPR3ResumeBuiltinKeyboard();
-    if (RT_FAILURE(rc1))
-        return rc1;
-
     matchingElementsArrayRef = IOHIDDeviceCopyMatchingElements(hidDevice, elementMatchingDict, kIOHIDOptionsTypeNone);
     if (matchingElementsArrayRef)
@@ -1849,6 +1849,11 @@
         VBoxKbdState_t *pKbd = (VBoxKbdState_t *)CFArrayGetValueAtIndex(pHidState->pDeviceCollection, i);
         if (pKbd && pKbd->idLocation == idLocation)
+        {
+            LogRel2(("Lookup USB HID Device by location ID 0x%X: found match\n", idLocation));
             return pKbd;
-    }
+        }
+    }
+
+    LogRel2(("Lookup USB HID Device by location ID 0x%X: no matches found:\n", idLocation));
 
     return NULL;
@@ -1883,10 +1888,13 @@
                 VBoxKbdState_t *pKbd = darwinUsbHidQueryKbdByLocationId((uint32_t)idLocation, pHidState);
 
-                rc = IOServiceAddInterestNotification(pHidState->pNotificationPrortRef, service, kIOGeneralInterest,
-                    darwinUsbHidGeneralInterestCb, pKbd, &pHidState->pUsbHidGeneralInterestNotify);
-
-                AssertMsg(rc == 0, ("Failed to add general interest notification"));
-
-                LogRel2(("Found HID device at location 0x%X: class 0x%X, subclass 0x%X\n", idLocation, idDeviceClass, idDeviceSubClass));
+                if (pKbd)
+                {
+                    rc = IOServiceAddInterestNotification(pHidState->pNotificationPrortRef, service, kIOGeneralInterest,
+                        darwinUsbHidGeneralInterestCb, pKbd, &pHidState->pUsbHidGeneralInterestNotify);
+
+                    AssertMsg(rc == 0, ("Failed to add general interest notification"));
+
+                    LogRel2(("Found HID device at location 0x%X: class 0x%X, subclass 0x%X\n", idLocation, idDeviceClass, idDeviceSubClass));
+                }
             }
 
Index: /trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp	(revision 49954)
+++ /trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp	(revision 49955)
@@ -1167,5 +1167,6 @@
         {
             while ((pDriver = (IOUSBHIDDriver *)pIter->getNextObject()))
-                pDriver->SuspendPort(false, 0);
+                if (pDriver->IsPortSuspended())
+                    pDriver->SuspendPort(false, 0);
 
             pIter->release();
