mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: stoyboyker@gmail.com
To: linux-kernel@vger.kernel.org
Cc: Stoyan Gaydarov <stoyboyker@gmail.com>, wim@iguana.be
Subject: [PATCH 08/13] [watchdog] changed ioctls to unlocked
Date: Tue, 24 Mar 2009 16:12:43 -0500	[thread overview]
Message-ID: <1237929168-15341-9-git-send-email-stoyboyker@gmail.com> (raw)

From: Stoyan Gaydarov <stoyboyker@gmail.com>

Signed-off-by: Stoyan Gaydarov <stoyboyker@gmail.com>
---
 drivers/watchdog/riowd.c |   37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/watchdog/riowd.c b/drivers/watchdog/riowd.c
index 09cb183..44058c1 100644
--- a/drivers/watchdog/riowd.c
+++ b/drivers/watchdog/riowd.c
@@ -86,9 +86,10 @@ static int riowd_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static int riowd_ioctl(struct inode *inode, struct file *filp,
-		       unsigned int cmd, unsigned long arg)
+static long riowd_ioctl(struct file *filp, unsigned int cmd,
+		       unsigned long arg)
 {
+	lock_kernel();
 	static struct watchdog_info info = {
 		.options		= WDIOF_SETTIMEOUT,
 		.firmware_version	= 1,
@@ -101,14 +102,18 @@ static int riowd_ioctl(struct inode *inode, struct file *filp,
 
 	switch (cmd) {
 	case WDIOC_GETSUPPORT:
-		if (copy_to_user(argp, &info, sizeof(info)))
+		if (copy_to_user(argp, &info, sizeof(info))) {
+			unlock_kernel();
 			return -EFAULT;
+		}
 		break;
 
 	case WDIOC_GETSTATUS:
 	case WDIOC_GETBOOTSTATUS:
-		if (put_user(0, (int __user *)argp))
+		if (put_user(0, (int __user *)argp)) {
+			unlock_kernel();
 			return -EFAULT;
+		}
 		break;
 
 	case WDIOC_KEEPALIVE:
@@ -116,34 +121,46 @@ static int riowd_ioctl(struct inode *inode, struct file *filp,
 		break;
 
 	case WDIOC_SETOPTIONS:
-		if (copy_from_user(&options, argp, sizeof(options)))
+		if (copy_from_user(&options, argp, sizeof(options))) {
+			unlock_kernel();
 			return -EFAULT;
+		}
 
 		if (options & WDIOS_DISABLECARD)
 			riowd_writereg(p, 0, WDTO_INDEX);
 		else if (options & WDIOS_ENABLECARD)
 			riowd_writereg(p, riowd_timeout, WDTO_INDEX);
-		else
+		else {
+			unlock_kernel();
 			return -EINVAL;
+		}
 
 		break;
 
 	case WDIOC_SETTIMEOUT:
-		if (get_user(new_margin, (int __user *)argp))
+		if (get_user(new_margin, (int __user *)argp)) {
+			unlock_kernel();
 			return -EFAULT;
-		if ((new_margin < 60) || (new_margin > (255 * 60)))
+		}
+		if ((new_margin < 60) || (new_margin > (255 * 60))) {
+			unlock_kernel();
 			return -EINVAL;
+		}
 		riowd_timeout = (new_margin + 59) / 60;
 		riowd_writereg(p, riowd_timeout, WDTO_INDEX);
 		/* Fall */
 
 	case WDIOC_GETTIMEOUT:
-		return put_user(riowd_timeout * 60, (int __user *)argp);
+		long ret = put_user(riowd_timeout * 60, (int __user *)argp);
+		unlock_kernel();
+		return ret;
 
 	default:
+		unlock_kernel();
 		return -EINVAL;
 	};
 
+	unlock_kernel();
 	return 0;
 }
 
@@ -162,7 +179,7 @@ static ssize_t riowd_write(struct file *file, const char __user *buf, size_t cou
 static const struct file_operations riowd_fops = {
 	.owner =	THIS_MODULE,
 	.llseek =	no_llseek,
-	.ioctl =	riowd_ioctl,
+	.unlocked_ioctl =	riowd_ioctl,
 	.open =		riowd_open,
 	.write =	riowd_write,
 	.release =	riowd_release,
-- 
1.6.2


             reply	other threads:[~2009-03-24 21:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-24 21:12 stoyboyker [this message]
2009-03-25  8:11 ` Wim Van Sebroeck

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=1237929168-15341-9-git-send-email-stoyboyker@gmail.com \
    --to=stoyboyker@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wim@iguana.be \
    /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

all inboxes | Powered by JetHome®