Index: trunk/src/VBox/Devices/Serial/UartCore.cpp
===================================================================
--- trunk/src/VBox/Devices/Serial/UartCore.cpp	(revision 90445)
+++ trunk/src/VBox/Devices/Serial/UartCore.cpp	(revision 90447)
@@ -1598,5 +1598,7 @@
     AssertMsg((uint32_t)cbAvail == cbAvail, ("Too much data available\n"));
 
-    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
+    int rcLock = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
+    AssertRCReturn(rcLock, rcLock);
+
     uint32_t cbAvailOld = ASMAtomicAddU32(&pThis->cbAvailRdr, (uint32_t)cbAvail);
     LogFlow(("    cbAvailRdr=%u -> cbAvailRdr=%u\n", cbAvailOld, cbAvail + cbAvailOld));
@@ -1615,6 +1617,6 @@
         }
     }
+
     PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
-
     return VINF_SUCCESS;
 }
@@ -1632,7 +1634,10 @@
 
     /* Set the transmitter empty bit because everything was sent. */
-    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
+    int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
+    AssertRCReturn(rcLock, rcLock);
+
     UART_REG_SET(pThis->uRegLsr, UART_REG_LSR_TEMT);
     uartIrqUpdate(pDevIns, pThis, pThisCC);
+
     PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
     return VINF_SUCCESS;
@@ -1652,8 +1657,10 @@
     AssertReturn(cbRead > 0, VERR_INVALID_PARAMETER);
 
-    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
+    int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
+    AssertRCReturn(rcLock, rcLock);
+
     uartR3TxQueueCopyFrom(pDevIns, pThis, pThisCC, pvBuf, cbRead, pcbRead);
+
     PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
-
     LogFlowFunc(("-> VINF_SUCCESS{*pcbRead=%zu}\n", *pcbRead));
     return VINF_SUCCESS;
@@ -1670,7 +1677,9 @@
     PUARTCORE   pThis   = pThisCC->pShared;
     PPDMDEVINS  pDevIns = pThisCC->pDevIns;
-
-    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
+    int const   rcLock  = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
+    AssertRCReturn(rcLock, rcLock);
+
     uartR3StsLinesUpdate(pDevIns, pThis, pThisCC, fNewStatusLines);
+
     PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
     return VINF_SUCCESS;
@@ -1687,8 +1696,10 @@
     PUARTCORE   pThis   = pThisCC->pShared;
     PPDMDEVINS  pDevIns = pThisCC->pDevIns;
-
-    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
+    int const   rcLock  = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
+    AssertRCReturn(rcLock, rcLock);
+
     UART_REG_SET(pThis->uRegLsr, UART_REG_LSR_BI);
     uartIrqUpdate(pDevIns, pThis, pThisCC);
+
     PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
     return VINF_SUCCESS;
@@ -1949,7 +1960,10 @@
             return VERR_PDM_MISSING_INTERFACE;
         }
-        PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
-        uartR3XferReset(pDevIns, pThis, pThisCC);
-        PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
+        rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
+        if (RT_SUCCESS(rc))
+        {
+            uartR3XferReset(pDevIns, pThis, pThisCC);
+            PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
+        }
     }
     else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
@@ -1957,8 +1971,10 @@
         pThisCC->pDrvBase = NULL;
         pThisCC->pDrvSerial = NULL;
-        rc = VINF_SUCCESS;
-        PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
-        uartR3XferReset(pDevIns, pThis, pThisCC);
-        PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
+        rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
+        if (RT_SUCCESS(rc))
+        {
+            uartR3XferReset(pDevIns, pThis, pThisCC);
+            PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
+        }
         LogRel(("Serial#%d: no unit\n", pDevIns->iInstance));
     }
@@ -1983,6 +1999,9 @@
     pThisCC->pDrvBase   = NULL;
     pThisCC->pDrvSerial = NULL;
-    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
+    int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
+    PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rcLock);
+
     uartR3XferReset(pDevIns, pThis, pThisCC);
+
     PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
 }
