From b3fbce13d6a0c30012e069c4a2131407beb31ab7 Mon Sep 17 00:00:00 2001 From: Tom Marshall Date: Mon, 6 Jun 2016 10:09:50 -0700 Subject: MtpServer: Fix concurrent access to mStorages * getStorage is called both internally with mMutex held and externally without mMutex held. Create getStorageLocked for internal use and make getStorage a wrapper. * hasStorage is only called internally with mMutex held. Make it a private method. Change-Id: I8f73310ad6cca14cd88b8e29f20cc181b3a4fac3 --- media/mtp/MtpServer.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'media/mtp/MtpServer.h') diff --git a/media/mtp/MtpServer.h b/media/mtp/MtpServer.h index 8bd0472..a79e199 100644 --- a/media/mtp/MtpServer.h +++ b/media/mtp/MtpServer.h @@ -95,8 +95,6 @@ public: virtual ~MtpServer(); MtpStorage* getStorage(MtpStorageID id); - inline bool hasStorage() { return mStorages.size() > 0; } - bool hasStorage(MtpStorageID id); void addStorage(MtpStorage* storage); void removeStorage(MtpStorage* storage); @@ -108,6 +106,10 @@ public: void sendObjectUpdated(MtpObjectHandle handle); private: + MtpStorage* getStorageLocked(MtpStorageID id); + inline bool hasStorage() { return mStorages.size() > 0; } + bool hasStorage(MtpStorageID id); + void sendStoreAdded(MtpStorageID id); void sendStoreRemoved(MtpStorageID id); void sendEvent(MtpEventCode code, uint32_t param1); -- cgit v1.1