From: Stoyan Gaydarov <[email protected]>
Signed-off-by: Stoyan Gaydarov <[email protected]>
---
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
Hi Stoyan,
> From: Stoyan Gaydarov <[email protected]>
>
> Signed-off-by: Stoyan Gaydarov <[email protected]>
> ---
> 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();
NAK. See commit c2dc3084010a7996c34e84bea14ff5346af7abd7 in the linux-2.6-watchdog-next tree that allready fixes this (and that will go to Linus one of these days for inclusion).
Kind regards,
Wim.