From be9c9900198891e97c228d244c3df064560c4756 Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Tue, 28 May 2019 13:45:26 +0100 Subject: [PATCH] Fix AppFuseMountScope.close() The boolean tracking whether the scope had been opened or not was never set before. Set it in open(), as was the case in the previous (non-binder) version of this class. Bug: 132901939 Test: monitor `adb shell mount` while browsing photos and verify the appfuse mounts don't build up over time Change-Id: Ia164ac4209126ed7e4d273c5fca4ababc0c66f2a --- .../com/android/server/StorageManagerService.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java index bbbec665020b4..58c966a6aa410 100644 --- a/services/core/java/com/android/server/StorageManagerService.java +++ b/services/core/java/com/android/server/StorageManagerService.java @@ -2842,8 +2842,9 @@ class StorageManagerService extends IStorageManager.Stub } } + /** Not thread safe */ class AppFuseMountScope extends AppFuseBridge.MountScope { - boolean opened = false; + private boolean mMounted = false; public AppFuseMountScope(int uid, int mountId) { super(uid, mountId); @@ -2852,8 +2853,9 @@ class StorageManagerService extends IStorageManager.Stub @Override public ParcelFileDescriptor open() throws NativeDaemonConnectorException { try { - return new ParcelFileDescriptor( - mVold.mountAppFuse(uid, mountId)); + final FileDescriptor fd = mVold.mountAppFuse(uid, mountId); + mMounted = true; + return new ParcelFileDescriptor(fd); } catch (Exception e) { throw new NativeDaemonConnectorException("Failed to mount", e); } @@ -2872,9 +2874,9 @@ class StorageManagerService extends IStorageManager.Stub @Override public void close() throws Exception { - if (opened) { + if (mMounted) { mVold.unmountAppFuse(uid, mountId); - opened = false; + mMounted = false; } } }