lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1599060933-8092-1-git-send-email-u0084500@gmail.com>
Date:   Wed,  2 Sep 2020 23:35:33 +0800
From:   cy_huang <u0084500@...il.com>
To:     linux@...ck-us.net, heikki.krogerus@...ux.intel.com
Cc:     gregkh@...uxfoundation.org, linux-usb@...r.kernel.org,
        linux-kernel@...r.kernel.org, cy_huang@...htek.com
Subject: [PATCH] usb: typec: tcpm: Fix if vbus before cc, hard_reset_count not reset issue

From: ChiYuan Huang <cy_huang@...htek.com>

Fix: If vbus event is before cc_event trigger, hard_reset_count
won't bt reset for some case.

Signed-off-by: ChiYuan Huang <cy_huang@...htek.com>
---
Below's the flow.

_tcpm_pd_vbus_off() -> run_state_machine to change state to SNK_UNATTACHED
call tcpm_snk_detach() -> tcpm_snk_detach() -> tcpm_detach()
tcpm_port_is_disconnected() will be called.
But port->attached is still true and port->cc1=open and port->cc2=open

It cause tcpm_port_is_disconnected return false, then hard_reset_count won't be reset.
After that, tcpm_reset_port() is called.
port->attached become false.

After that, cc now trigger cc_change event, the hard_reset_count will be kept.
Even tcpm_detach will be called, due to port->attached is false, tcpm_detach()
will directly return.

CC_EVENT will only trigger drp toggling again.
---
 drivers/usb/typec/tcpm/tcpm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index a48e3f90..5c73e1d 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -2797,8 +2797,7 @@ static void tcpm_detach(struct tcpm_port *port)
 		port->tcpc->set_bist_data(port->tcpc, false);
 	}
 
-	if (tcpm_port_is_disconnected(port))
-		port->hard_reset_count = 0;
+	port->hard_reset_count = 0;
 
 	tcpm_reset_port(port);
 }
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ