From cda9b2a500ce546d3fa8b7313b7e9aa3ec4b5222 Mon Sep 17 00:00:00 2001 From: shaozhongqi Date: Tue, 11 Feb 2020 15:27:10 +0800 Subject: [PATCH] storaged:Thread out of sync will cause null pointer crash if other process binder calls dumpPerfHistory when storaged is started, there will be a problem with the storage_sp null pointer Test: Manual Bug: 149251684 Change-Id: I9bf61ceb7c34326e95f2355129714d28153a994c Signed-off-by: shaozhongqi --- storaged/main.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/storaged/main.cpp b/storaged/main.cpp index e35bd6fe7..a7bda1492 100644 --- a/storaged/main.cpp +++ b/storaged/main.cpp @@ -46,11 +46,6 @@ sp storaged_sp; // Function of storaged's main thread void* storaged_main(void* /* unused */) { - storaged_sp = new storaged_t(); - - storaged_sp->init(); - storaged_sp->report_storage_info(); - LOG(INFO) << "storaged: Start"; for (;;) { @@ -123,6 +118,9 @@ int main(int argc, char** argv) { if (flag_main_service) { // start main thread // Start the main thread of storaged + storaged_sp = new storaged_t(); + storaged_sp->init(); + storaged_sp->report_storage_info(); pthread_t storaged_main_thread; errno = pthread_create(&storaged_main_thread, NULL, storaged_main, NULL); if (errno != 0) {