Index: /trunk/src/VBox/Main/MachineImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MachineImpl.cpp	(revision 31312)
+++ /trunk/src/VBox/Main/MachineImpl.cpp	(revision 31313)
@@ -3420,32 +3420,36 @@
                                         medium,
                                         *pMediumLockList);
-        if (FAILED(rc)) return rc;
-        rc = pMediumLockList->Lock();
-        if (FAILED(rc))
-            return setError(rc,
-                            tr("Could not lock medium when creating diff '%s'"),
-                            diff->getLocationFull().c_str());
-
-        /* will leave the lock before the potentially lengthy operation, so
-         * protect with the special state */
-        MachineState_T oldState = mData->mMachineState;
-        setMachineState(MachineState_SettingUp);
-
-        mediumLock.leave();
-        treeLock.leave();
-        alock.leave();
-
-        rc = medium->createDiffStorage(diff,
-                                       MediumVariant_Standard,
-                                       pMediumLockList,
-                                       NULL /* aProgress */,
-                                       true /* aWait */,
-                                       &fNeedsSaveSettings);
-
-        alock.enter();
-        treeLock.enter();
-        mediumLock.enter();
-
-        setMachineState(oldState);
+        if (SUCCEEDED(rc))
+        {
+            rc = pMediumLockList->Lock();
+            if (FAILED(rc))
+                setError(rc,
+                         tr("Could not lock medium when creating diff '%s'"),
+                         diff->getLocationFull().c_str());
+            else
+            {
+                /* will leave the lock before the potentially lengthy operation, so
+                 * protect with the special state */
+                MachineState_T oldState = mData->mMachineState;
+                setMachineState(MachineState_SettingUp);
+
+                mediumLock.leave();
+                treeLock.leave();
+                alock.leave();
+
+                rc = medium->createDiffStorage(diff,
+                                               MediumVariant_Standard,
+                                               pMediumLockList,
+                                               NULL /* aProgress */,
+                                               true /* aWait */,
+                                               &fNeedsSaveSettings);
+
+                alock.enter();
+                treeLock.enter();
+                mediumLock.enter();
+
+                setMachineState(oldState);
+            }
+        }
 
         /* Unlock the media and free the associated memory. */
