From a5bbb5e3c13db677a30d26f2a2c3487dfe28f66a Mon Sep 17 00:00:00 2001 From: Keun-young Park Date: Mon, 13 Mar 2017 18:02:50 -0700 Subject: [PATCH] make shutdown safe for double calls. - In new shutdown sequence, volume shutdown is requested in two places: system_server and init. - Make VolumeManager.shutdown safe for double calls. It crashed before this change. bug: 36004738 Test: reboot and check last_kmsg for crash / vdc timeout Change-Id: I296913959b2647b65d66553073f2032545beba57 --- VolumeManager.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/VolumeManager.cpp b/VolumeManager.cpp index 4a649bb..927c660 100644 --- a/VolumeManager.cpp +++ b/VolumeManager.cpp @@ -633,8 +633,13 @@ int VolumeManager::reset() { return 0; } +// Can be called twice (sequentially) during shutdown. should be safe for that. int VolumeManager::shutdown() { + if (mInternalEmulated == nullptr) { + return 0; // already shutdown + } mInternalEmulated->destroy(); + mInternalEmulated = nullptr; for (const auto& disk : mDisks) { disk->destroy(); }