From: H Hartley Sweeten <hartleys@visionengravers.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Cc: greg@kroah.com, ss@aao.gov.au
Subject: [PATCH] staging/dt3155: make copy_{to/from}_user and put_user typesafe
Date: Thu, 4 Mar 2010 10:20:18 -0700 [thread overview]
Message-ID: <201003041020.19046.hartleys@visionengravers.com> (raw)
This makes the kernel to user space data transfers typesafe and removes
a number of unnecessary (void *) casts.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Greg Kroah-Hartman <greg@kroah.com>
Cc: Scott Smedley <ss@aao.gov.au>
---
diff --git a/drivers/staging/dt3155/dt3155_drv.c b/drivers/staging/dt3155/dt3155_drv.c
index a67c622..76c9d94 100644
--- a/drivers/staging/dt3155/dt3155_drv.c
+++ b/drivers/staging/dt3155/dt3155_drv.c
@@ -528,6 +528,7 @@ static int dt3155_ioctl(struct inode *inode,
unsigned long arg)
{
int minor = MINOR(inode->i_rdev); /* What device are we ioctl()'ing? */
+ void __user *up = (void __user *)arg;
if ( minor >= MAXBOARDS || minor < 0 )
return -ENODEV;
@@ -554,7 +555,7 @@ static int dt3155_ioctl(struct inode *inode,
{
struct dt3155_config_s tmp;
- if (copy_from_user((void *)&tmp, (void *) arg, sizeof(tmp)))
+ if (copy_from_user(&tmp, up, sizeof(tmp)))
return -EFAULT;
/* check for valid settings */
if (tmp.rows > DT3155_MAX_ROWS ||
@@ -572,8 +573,7 @@ static int dt3155_ioctl(struct inode *inode,
}
case DT3155_GET_CONFIG:
{
- if (copy_to_user((void *) arg, (void *) &dt3155_status[minor],
- sizeof(dt3155_status_t) ))
+ if (copy_to_user(up, &dt3155_status[minor], sizeof(dt3155_status_t)))
return -EFAULT;
return 0;
}
@@ -593,8 +593,7 @@ static int dt3155_ioctl(struct inode *inode,
return 0;
quick_stop(minor);
- if (copy_to_user((void *) arg, (void *) &dt3155_status[minor],
- sizeof(dt3155_status_t)))
+ if (copy_to_user(up, &dt3155_status[minor], sizeof(dt3155_status_t)))
return -EFAULT;
return 0;
}
@@ -617,8 +616,7 @@ static int dt3155_ioctl(struct inode *inode,
}
dt3155_init_isr(minor);
- if (copy_to_user( (void *) arg, (void *) &dt3155_status[minor],
- sizeof(dt3155_status_t)))
+ if (copy_to_user(up, &dt3155_status[minor], sizeof(dt3155_status_t)))
return -EFAULT;
return 0;
}
@@ -819,11 +817,11 @@ static ssize_t dt3155_read(struct file *filep, char __user *buf,
/* make this an offset */
offset = frame_info_p->addr - dt3155_status[minor].mem_addr;
- put_user(offset, (unsigned int *) buf);
+ put_user(offset, (unsigned int __user *)buf);
buf += sizeof(u32);
- put_user( dt3155_status[minor].fbuffer.frame_count, (unsigned int *) buf);
+ put_user( dt3155_status[minor].fbuffer.frame_count, (unsigned int __user *)buf);
buf += sizeof(u32);
- put_user(dt3155_status[minor].state, (unsigned int *) buf);
+ put_user(dt3155_status[minor].state, (unsigned int __user *)buf);
buf += sizeof(u32);
if (copy_to_user(buf, frame_info_p, sizeof(frame_info_t)))
return -EFAULT;
next reply other threads:[~2010-03-04 17:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-04 17:20 H Hartley Sweeten [this message]
2010-03-11 0:01 ` Simon Horman
2010-03-11 0:19 ` H Hartley Sweeten
2010-03-11 3:20 ` Simon Horman
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=201003041020.19046.hartleys@visionengravers.com \
--to=hartleys@visionengravers.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ss@aao.gov.au \
/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®