mInternalEmulated could be used after shutdown() called
It fixes the findvolume() / reset() use-after-free issue after
shutdown called to avoid vold crash.
Fixes: a5bbb5e3c1
("make shutdown safe for double calls.")
Change-Id: I50f216141b20da08549080291091dc5690c00ffe
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
This commit is contained in:
parent
1647759651
commit
d263da8807
1 changed files with 8 additions and 3 deletions
|
@ -365,7 +365,10 @@ std::shared_ptr<android::vold::Disk> VolumeManager::findDisk(const std::string&
|
|||
}
|
||||
|
||||
std::shared_ptr<android::vold::VolumeBase> VolumeManager::findVolume(const std::string& id) {
|
||||
if (mInternalEmulated->getId() == id) {
|
||||
// Vold could receive "mount" after "shutdown" command in the extreme case.
|
||||
// If this happens, mInternalEmulated will equal nullptr and
|
||||
// we need to deal with it in order to avoid null pointer crash.
|
||||
if (mInternalEmulated != nullptr && mInternalEmulated->getId() == id) {
|
||||
return mInternalEmulated;
|
||||
}
|
||||
for (const auto& disk : mDisks) {
|
||||
|
@ -623,8 +626,10 @@ next:
|
|||
int VolumeManager::reset() {
|
||||
// Tear down all existing disks/volumes and start from a blank slate so
|
||||
// newly connected framework hears all events.
|
||||
if (mInternalEmulated != nullptr) {
|
||||
mInternalEmulated->destroy();
|
||||
mInternalEmulated->create();
|
||||
}
|
||||
for (const auto& disk : mDisks) {
|
||||
disk->destroy();
|
||||
disk->create();
|
||||
|
|
Loading…
Reference in a new issue