From: Alan Stern <stern@rowland.harvard.edu>
To: Salah Triki <salah.triki@gmail.com>
Cc: Keith Packard <keithp@keithp.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: misc: chaoskey: get lock before calling usb_[disable|enable]_autosuspend()
Date: Mon, 2 Aug 2021 20:58:34 -0400 [thread overview]
Message-ID: <20210803005834.GB349864@rowland.harvard.edu> (raw)
In-Reply-To: <20210802222205.GA1389315@pc>
On Mon, Aug 02, 2021 at 11:22:05PM +0100, Salah Triki wrote:
> Based on the documentation of usb_[disable|enable]_autosuspend(), the
> caller must hold udev's device lock.
>
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
> ---
> drivers/usb/misc/chaoskey.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c
> index 87067c3d6109..8af00be7b9e8 100644
> --- a/drivers/usb/misc/chaoskey.c
> +++ b/drivers/usb/misc/chaoskey.c
> @@ -206,7 +206,9 @@ static int chaoskey_probe(struct usb_interface *interface,
> if (!dev->hwrng_registered)
> usb_err(interface, "Unable to register with hwrng");
>
> + usb_lock_device(udev);
> usb_enable_autosuspend(udev);
> + usb_unlock_device(udev);
Not needed (indeed, actively harmful). When this code runs it already
holds the device lock, because it is part of a probe routine.
Alan Stern
prev parent reply other threads:[~2021-08-03 0:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-02 22:22 [PATCH] usb: misc: chaoskey: get lock before calling usb_[disable|enable]_autosuspend() Salah Triki
2021-08-03 0:58 ` Alan Stern [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=20210803005834.GB349864@rowland.harvard.edu \
--to=stern@rowland.harvard.edu \
--cc=gregkh@linuxfoundation.org \
--cc=keithp@keithp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=salah.triki@gmail.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).