[PATCH] usb: check for signals in chaoskey read function

From: Keith Packard
Date: Mon Feb 15 2016 - 21:51:04 EST


Call signal_pending before reading a chunk of data from the device so
that long read operations can be interrupted with a signal.

Signed-off-by: Keith Packard <keithp@xxxxxxxxxx>
---
drivers/usb/misc/chaoskey.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c
index 23c7948..ab87db2 100644
--- a/drivers/usb/misc/chaoskey.c
+++ b/drivers/usb/misc/chaoskey.c
@@ -394,6 +394,13 @@ static ssize_t chaoskey_read(struct file *file,
if (result)
goto bail;
if (dev->valid == dev->used) {
+
+ if (signal_pending(current)) {
+ result = -ERESTARTSYS;
+ mutex_unlock(&dev->lock);
+ goto bail;
+ }
+
result = _chaoskey_fill(dev);
if (result) {
mutex_unlock(&dev->lock);
--
2.7.0