Skip to contentSkip to conversation

USB: usbtmc: use interruptible sleep in usbtmc_read

PATCH New Oliver Neukum 1 participant 1 message Apr 30, 2025 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: usbtmc: use interruptible sleep in usbtmc_read

usbtmc_read() calls usbtmc_generic_read() which uses interruptible sleep, but usbtmc_read() itself uses uninterruptble sleep for mutual exclusion between threads. That makes no sense.
Both should use interruptible sleep.

Fixes 5b775f672cc99 ("USB: add USB test and measurement class driver")
---
 drivers/usb/class/usbtmc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/class/usbtmc.c +5 -1
index 34e46ef308ab..634c3bcbb413 100644
@@ -1380,7 +1380,10 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf,
 	if (!buffer)
 		return -ENOMEM;
 
-	mutex_lock(&data->io_mutex);
+	retval = mutex_lock_interruptible(&data->io_mutex);
+	if (retval < 0)
+		goto exit_nolock;
+
 	if (data->zombie) {
 		retval = -ENODEV;
 		goto exit;
@@ -1503,6 +1506,7 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf,
 
 exit:
 	mutex_unlock(&data->io_mutex);
+exit_nolock:
 	kfree(buffer);
 	return retval;
 }
Signature · 1 line
2.49.0