From f71707916fdf11715bde10a7b76e92426ea1f32f Mon Sep 17 00:00:00 2001 From: Zim Date: Wed, 17 Jun 2020 14:56:10 +0100 Subject: [PATCH] Unmount public volume if FUSE mount fails Sometimes, during early boot, a public volume may be created before the user is unlocked and the mount may fail. This mount failure does not revert the lower fs mounts (sdcardfs and vfat). Subsequent mount attempts will then fail because we'd attempt to mount vfat on already mounted /mnt/media_rw/ Bug: 158489548 Test: Resilient to an artificial sleep in StorageManagerService#completeUnlockUser to delay user unlock longer than public volume mount Change-Id: I9a1574596434a2eb6b2553c0c9220c2118c7e4fd --- model/PublicVolume.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/model/PublicVolume.cpp b/model/PublicVolume.cpp index 64b5dfa..9ca782b 100644 --- a/model/PublicVolume.cpp +++ b/model/PublicVolume.cpp @@ -238,6 +238,7 @@ status_t PublicVolume::doMount() { if (result != 0) { LOG(ERROR) << "Failed to mount public fuse volume"; + doUnmount(); return -result; } @@ -247,6 +248,8 @@ status_t PublicVolume::doMount() { bool is_ready = false; callback->onVolumeChecking(std::move(fd), getPath(), getInternalPath(), &is_ready); if (!is_ready) { + LOG(ERROR) << "Failed to complete public volume mount"; + doUnmount(); return -EIO; } } -- 2.11.0