From 910ce0ff0852418c1a1e126bf0b083dcf24d5899 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 --- adb/daemon/usb.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp index 1e3701582..0a116abb3 100644 --- a/adb/daemon/usb.cpp +++ b/adb/daemon/usb.cpp @@ -310,11 +310,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; @@ -324,11 +326,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;