From 94fb36bf779f185f812c7f46f86015d9988acf62 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Wed, 1 May 2019 16:53:53 -0700 Subject: [PATCH] adbd: avoid starting multiple worker threads. A previous patch intended to make receiving multiple FUNCTIONFS_ENABLEs non-fatal, but failed to do so because we would try to spawn another worker thread and hit a different assertion. Bug: http://b/130638368 Test: echo mem | adb shell "su 0 sh -c 'cat > /sys/power/state'" Change-Id: I53456112244d8b4f7d26df6ec6961389fca70498 (cherry picked from commit 910ce0ff0852418c1a1e126bf0b083dcf24d5899) --- adb/daemon/usb.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp index 3b29ab5fc..e6a19a521 100644 --- a/adb/daemon/usb.cpp +++ b/adb/daemon/usb.cpp @@ -308,11 +308,13 @@ struct UsbFfsConnection : public Connection { if (bound) { LOG(WARNING) << "received FUNCTIONFS_BIND while already bound?"; running = false; + break; } if (enabled) { LOG(WARNING) << "received FUNCTIONFS_BIND while already enabled?"; running = false; + break; } bound = true; @@ -322,11 +324,13 @@ struct UsbFfsConnection : public Connection { if (!bound) { LOG(WARNING) << "received FUNCTIONFS_ENABLE while not bound?"; running = false; + break; } if (enabled) { LOG(WARNING) << "received FUNCTIONFS_ENABLE while already enabled?"; running = false; + break; } enabled = true;