linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Keith Packard <keithp@keithp.com>
To: linux-usb@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, Keith Packard <keithp@keithp.com>
Subject: [PATCH] usb: check for signals in chaoskey read function
Date: Mon, 15 Feb 2016 18:49:32 -0800	[thread overview]
Message-ID: <1455590972-2120-1-git-send-email-keithp@keithp.com> (raw)

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@keithp.com>
---
 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

             reply	other threads:[~2016-02-16  2:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16  2:49 Keith Packard [this message]
2016-02-16  8:24 ` [PATCH] usb: check for signals in chaoskey read function Oliver Neukum
2016-02-16 19:09   ` Keith Packard
2016-02-17 14:59     ` Oliver Neukum
2016-02-17 18:05       ` Keith Packard
2016-02-17 18:21         ` Keith Packard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455590972-2120-1-git-send-email-keithp@keithp.com \
    --to=keithp@keithp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).