public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: storage: realtek_cr: get lock before calling usb_enable_autosuspend()
@ 2021-08-02 23:03 Salah Triki
  2021-08-03  0:56 ` Alan Stern
  0 siblings, 1 reply; 2+ messages in thread
From: Salah Triki @ 2021-08-02 23:03 UTC (permalink / raw)
  To: Alan Stern, Greg Kroah-Hartman; +Cc: linux-usb, usb-storage, linux-kernel

Based on the documentation of usb_enable_autosuspend(), the
caller must hold udev's device lock.

Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
 drivers/usb/storage/realtek_cr.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
index 3789698d9d3c..6948d6fdad39 100644
--- a/drivers/usb/storage/realtek_cr.c
+++ b/drivers/usb/storage/realtek_cr.c
@@ -918,9 +918,13 @@ static int realtek_cr_autosuspend_setup(struct us_data *us)
 	timer_setup(&chip->rts51x_suspend_timer, rts51x_suspend_timer_fn, 0);
 	fw5895_init(us);
 
+	usb_lock_device(us->pusb_dev);
+
 	/* enable autosuspend function of the usb device */
 	usb_enable_autosuspend(us->pusb_dev);
 
+	usb_unlock_device(us->pusb_dev);
+
 	return 0;
 }
 #endif
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-03  0:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-02 23:03 [PATCH] usb: storage: realtek_cr: get lock before calling usb_enable_autosuspend() Salah Triki
2021-08-03  0:56 ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox