From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751511AbdESIOz (ORCPT ); Fri, 19 May 2017 04:14:55 -0400 Received: from gw.hale.at ([89.26.116.210]:34556 "EHLO gw.hale.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750793AbdESIOy (ORCPT ); Fri, 19 May 2017 04:14:54 -0400 X-HALE-Mailborder-Watermark: 1495786491.56113@2dAUOZYQHLRzx2sv1fRCwg X-HALE-Mailborder-From: michael.thalmeier@hale.at X-HALE-Mailborder-SpamCheck: not spam, SpamAssassin (nicht zwischen gespeichert, Wertung=-2.898, benoetigt 3, autolearn=not spam, ALL_TRUSTED -1.00, BAYES_00 -1.90, SURBL_BLOCKED 0.00, URIBL_BLOCKED 0.00) X-HALE-Mailborder-IP-Protocol: IPv4 X-HALE-Mailborder: Found to be clean X-HALE-Mailborder-ID: 472E32C9411.A85A9 X-HALE-Mailborder-Information: Please contact your admin for more information Date: Fri, 19 May 2017 10:14:17 +0200 From: Michael Thalmeier To: Peter Chen Cc: Peter Chen , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: chipidea: debug: check before accessing ci_role Message-ID: <20170519081417.GA21030@entw49.hale> References: <20170518141414.30798-1-michael.thalmeier@hale.at> <20170519011540.GB7460@b29397-desktop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170519011540.GB7460@b29397-desktop> User-Agent: Mutt/1.8.0 (2017-02-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 19, 2017 at 09:15:40AM +0800, Peter Chen wrote: > On Thu, May 18, 2017 at 04:14:14PM +0200, Michael Thalmeier wrote: > > ci_role BUGs when the role is >= CI_ROLE_END. > > > > Signed-off-by: Michael Thalmeier > > --- > > drivers/usb/chipidea/debug.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c > > index 6d23eed..1c31e8a 100644 > > --- a/drivers/usb/chipidea/debug.c > > +++ b/drivers/usb/chipidea/debug.c > > @@ -294,7 +294,8 @@ static int ci_role_show(struct seq_file *s, void *data) > > { > > struct ci_hdrc *ci = s->private; > > > > - seq_printf(s, "%s\n", ci_role(ci)->name); > > + if (ci->role != CI_ROLE_END) > > + seq_printf(s, "%s\n", ci_role(ci)->name); > > > > return 0; > > } > > By the way, how can you trigger this issue? It is quite easy to trigger. I have an USB OTG adapter cable connected to the micro-USB port of my device. When the cable is connected, the port has the "host" role. When disconnected, the role changes to "gadget". When polling (1 second interval) the role file while connecting/disconnecting the USB OTG cable, the error occurs within the first few tries. > Do you mind sending another patch to fix the same issue for ci_role_show > at core.c? I did not see, that there is now another place this is used. Will send a patch later. > > -- > > Best Regards, > Peter Chen Regards, Michael