lkml.org 
[lkml]   [2021]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] usb: misc: chaoskey: get lock before calling usb_[disable|enable]_autosuspend()
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

\
 
 \ /
  Last update: 2021-08-03 02:59    [W:1.186 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site