Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: yurex: make waiting on yurex_write interruptible
@ 2024-09-23 14:16 Oliver Neukum
  2024-09-23 20:15 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Oliver Neukum @ 2024-09-23 14:16 UTC (permalink / raw)
  To: gregkh, linux-usb, stable; +Cc: Oliver Neukum

The IO yurex_write() needs to wait for in order to have a device
ready for writing again can take a long time time.
Consequently the sleep is done in an interruptible state.
Therefore others waiting for yurex_write() itself to finish should
use mutex_lock_interruptible.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Fixes: 6bc235a2e24a5 ("USB: add driver for Meywa-Denki & Kayac YUREX")
---
 drivers/usb/misc/yurex.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
index 4a9859e03f6b..0deffdc8205f 100644
--- a/drivers/usb/misc/yurex.c
+++ b/drivers/usb/misc/yurex.c
@@ -430,7 +430,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
 			   size_t count, loff_t *ppos)
 {
 	struct usb_yurex *dev;
-	int i, set = 0, retval = 0;
+	int i, set = 0, retval;
 	char buffer[16 + 1];
 	char *data = buffer;
 	unsigned long long c, c2 = 0;
@@ -444,7 +444,10 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
 	if (count == 0)
 		goto error;
 
-	mutex_lock(&dev->io_mutex);
+	retval = mutex_lock_interruptible(&dev->io_mutex);
+	if (retval < 0)
+		return -EINTR;
+
 	if (dev->disconnected) {		/* already disconnected */
 		mutex_unlock(&dev->io_mutex);
 		retval = -ENODEV;
-- 
2.46.1


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

end of thread, other threads:[~2024-09-23 20:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-23 14:16 [PATCH] usb: yurex: make waiting on yurex_write interruptible Oliver Neukum
2024-09-23 20:15 ` kernel test robot

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