Merge "Handle failures after partial mounts"
diff --git a/model/EmulatedVolume.cpp b/model/EmulatedVolume.cpp
index 054a58b..082dea5 100644
--- a/model/EmulatedVolume.cpp
+++ b/model/EmulatedVolume.cpp
@@ -245,12 +245,19 @@
             bool is_ready = false;
             callback->onVolumeChecking(std::move(fd), getPath(), getInternalPath(), &is_ready);
             if (!is_ready) {
+                fd.reset();
+                doUnmount();
                 return -EIO;
             }
         }
 
         // Only do the bind-mounts when we know for sure the FUSE daemon can resolve the path.
-        return mountFuseBindMounts();
+        status_t res = mountFuseBindMounts();
+        if (res != OK) {
+            fd.reset();
+            doUnmount();
+        }
+        return res;
     }
 
     return OK;