public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: "linux@roeck-us.net" <linux@roeck-us.net>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	Jun Li <jun.li@nxp.com>, dl-linux-imx <linux-imx@nxp.com>
Subject: Re: [EXT] Re: [PATCH] usb: typec: tcpm: fix tcpm unregister port but leave a pending timer
Date: Fri, 19 Nov 2021 11:25:18 +0200	[thread overview]
Message-ID: <YZdtfsCkp1hQpglh@kuha.fi.intel.com> (raw)
In-Reply-To: <DB8PR04MB68433EAC3FDD82834FDC0E768C9B9@DB8PR04MB6843.eurprd04.prod.outlook.com>

On Thu, Nov 18, 2021 at 03:00:16PM +0000, Xu Yang wrote:
> Hi,
> 
> > -----Original Message-----
> > From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > Sent: Thursday, November 18, 2021 9:18 PM
> > To: Xu Yang <xu.yang_2@nxp.com>
> > Cc: linux@roeck-us.net; gregkh@linuxfoundation.org; linux-
> > usb@vger.kernel.org; Jun Li <jun.li@nxp.com>; dl-linux-imx <linux-
> > imx@nxp.com>
> > Subject: [EXT] Re: [PATCH] usb: typec: tcpm: fix tcpm unregister port but
> > leave a pending timer
> > 
> > Caution: EXT Email
> > 
> > Hi,
> > 
> > On Thu, Nov 18, 2021 at 05:23:52PM +0800, Xu Yang wrote:
> > > @@ -6428,6 +6432,9 @@ void tcpm_unregister_port(struct tcpm_port
> > > *port)  {
> > >       int i;
> > 
> > You need to take the port lock here, no?
> > 
> >         mutex_lock(&port->lock);
> > 
> > > +     kthread_destroy_worker(port->wq);
> > > +     port->wq = NULL;
> > 
> >         mutex_unlock(&port->lock);
> 
> I think we should not take the port lock before kthread_destroy_worker() since
> a deadlock might occur. Considering a work is pending and tcpm_unregister_port
> is called at this time, the worker needs to flush all the works after taking
> the port lock in tcpm_unregister_port(). However, the work can't take the port
> lock anymore.

The point is that you create a race with that code. If the port lock
is not useful in this case, there needs to be something else.

thanks,

-- 
heikki

      reply	other threads:[~2021-11-19  9:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18  9:23 [PATCH] usb: typec: tcpm: fix tcpm unregister port but leave a pending timer Xu Yang
2021-11-18 13:18 ` Heikki Krogerus
2021-11-18 14:38   ` Guenter Roeck
2021-11-18 15:00   ` [EXT] " Xu Yang
2021-11-19  9:25     ` Heikki Krogerus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YZdtfsCkp1hQpglh@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jun.li@nxp.com \
    --cc=linux-imx@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=xu.yang_2@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox