From: Guenter Roeck <linux@roeck-us.net>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Xu Yang <xu.yang_2@nxp.com>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
jun.li@nxp.com, linux-imx@nxp.com
Subject: Re: [PATCH] usb: typec: tcpm: fix tcpm unregister port but leave a pending timer
Date: Thu, 18 Nov 2021 06:38:00 -0800 [thread overview]
Message-ID: <c4b51f6d-fd3c-1fb3-6ee3-18ca37dd171c@roeck-us.net> (raw)
In-Reply-To: <YZZSpffDfPd/CJDX@kuha.fi.intel.com>
On 11/18/21 5:18 AM, Heikki Krogerus wrote:
> 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 don't think the timer code runs under the lock, so that won't help.
But, yes, the code is inherently racy. At the very least, port->wq
would have to be set to NULL first, but even that would have to be
synchronized. I wonder how other drivers handle that situation.
Guenter
>> hrtimer_cancel(&port->send_discover_timer);
>> hrtimer_cancel(&port->enable_frs_timer);
>> hrtimer_cancel(&port->vdm_state_machine_timer);
>> @@ -6439,7 +6446,6 @@ void tcpm_unregister_port(struct tcpm_port *port)
>> typec_unregister_port(port->typec_port);
>> usb_role_switch_put(port->role_sw);
>> tcpm_debugfs_exit(port);
>> - kthread_destroy_worker(port->wq);
>> }
>> EXPORT_SYMBOL_GPL(tcpm_unregister_port);
>
> thanks,
>
next prev parent reply other threads:[~2021-11-18 14:38 UTC|newest]
Thread overview: 6+ 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 [this message]
2021-11-18 15:00 ` [EXT] " Xu Yang
2021-11-19 9:25 ` Heikki Krogerus
2021-11-22 5:14 Xu Yang
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=c4b51f6d-fd3c-1fb3-6ee3-18ca37dd171c@roeck-us.net \
--to=linux@roeck-us.net \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=jun.li@nxp.com \
--cc=linux-imx@nxp.com \
--cc=linux-usb@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).