usb: misc: chaoskey: get lock before calling usb_[disable|enable]_autosuspend()
Subsystems (2)
PATCH 1/1 usb: misc: chaoskey: get lock before calling usb_[disable|enable]_autosuspend()
Based on the documentation of usb_[disable|enable]_autosuspend(), the caller must hold udev's device lock.
Signed-off-by Salah Triki <[email protected]>
--- drivers/usb/misc/chaoskey.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/misc/chaoskey.c +2 -0
@@ -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);usb_dbg (interface,"chaoskey probe success, size %d" , dev->size);return 0 ;
Signature · 1 line
2.25.1
Quoted 13 lines · Salah Triki
Based on the documentation of usb_[disable|enable]_autosuspend(), the caller must hold udev's device lock.
Signed-off-by Salah Triki <[email protected]>--- drivers/usb/misc/chaoskey.c | 2 ++ 1 file changed, 2 insertions(+)drivers/usb/misc/chaoskey.c +0
-0
drivers/usb/misc/chaoskey.c static int chaoskey_probe(struct usb_interface *interface, · line 211
Quoted 6 lines
drivers/usb/misc/chaoskey.c +2
-0@@ -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