From b66356cab6cd47ecbe26513f36614dda1052eb11 Mon Sep 17 00:00:00 2001 From: Benoit Goby Date: Mon, 1 Apr 2013 17:39:06 -0700 Subject: [PATCH] adb: Prevent registering usb_disconnect twice adbd can receive multiple AUTH_RSAPUBLICKEY packets. This happens for example when booting with usb attached when we retry authenticating after the framework is done booting. Make sure usb_disconnect is only registered once, otherwise this creates a loop in the disconnects list. Bug: 8504991 Change-Id: Ia1f9a37005dd17b7eefee1493d622e1679263eea --- adb/adb_auth_client.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/adb/adb_auth_client.c b/adb/adb_auth_client.c index efc49ebb5..763b448d7 100644 --- a/adb/adb_auth_client.c +++ b/adb/adb_auth_client.c @@ -161,7 +161,7 @@ int adb_auth_verify(void *token, void *sig, int siglen) static void usb_disconnected(void* unused, atransport* t) { - D("USB disconnect"); + D("USB disconnect\n"); remove_transport_disconnect(usb_transport, &usb_disconnect); usb_transport = NULL; needs_retry = false; @@ -175,7 +175,7 @@ static void adb_auth_event(int fd, unsigned events, void *data) if (events & FDE_READ) { ret = unix_read(fd, response, sizeof(response)); if (ret < 0) { - D("Framework disconnect"); + D("Framework disconnect\n"); if (usb_transport) fdevent_remove(&usb_transport->auth_fde); framework_fd = -1; @@ -192,8 +192,10 @@ void adb_auth_confirm_key(unsigned char *key, size_t len, atransport *t) char msg[MAX_PAYLOAD]; int ret; - usb_transport = t; - add_transport_disconnect(t, &usb_disconnect); + if (!usb_transport) { + usb_transport = t; + add_transport_disconnect(t, &usb_disconnect); + } if (framework_fd < 0) { D("Client not connected\n");