Commit 1a85f207 authored by Emilio G. Cota's avatar Emilio G. Cota Committed by Greg Kroah-Hartman

staging: vme_user: mark user-space buffers with __user

Signed-off-by: default avatarEmilio G. Cota <cota@braap.org>
[martyn.welch@ge.com: modified to remove checkpatch warnings]
Signed-off-by: default avatarMartyn Welch <martyn.welch@ge.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 0a81a0f7
...@@ -129,8 +129,9 @@ static const int type[VME_DEVS] = { MASTER_MINOR, MASTER_MINOR, ...@@ -129,8 +129,9 @@ static const int type[VME_DEVS] = { MASTER_MINOR, MASTER_MINOR,
static int vme_user_open(struct inode *, struct file *); static int vme_user_open(struct inode *, struct file *);
static int vme_user_release(struct inode *, struct file *); static int vme_user_release(struct inode *, struct file *);
static ssize_t vme_user_read(struct file *, char *, size_t, loff_t *); static ssize_t vme_user_read(struct file *, char __user *, size_t, loff_t *);
static ssize_t vme_user_write(struct file *, const char *, size_t, loff_t *); static ssize_t vme_user_write(struct file *, const char __user *, size_t,
loff_t *);
static loff_t vme_user_llseek(struct file *, loff_t, int); static loff_t vme_user_llseek(struct file *, loff_t, int);
static long vme_user_unlocked_ioctl(struct file *, unsigned int, unsigned long); static long vme_user_unlocked_ioctl(struct file *, unsigned int, unsigned long);
...@@ -246,7 +247,7 @@ static ssize_t resource_to_user(int minor, char __user *buf, size_t count, ...@@ -246,7 +247,7 @@ static ssize_t resource_to_user(int minor, char __user *buf, size_t count,
* page) transfers will lock the user space buffer into memory and then * page) transfers will lock the user space buffer into memory and then
* transfer the data directly from the user space buffers out to VME. * transfer the data directly from the user space buffers out to VME.
*/ */
static ssize_t resource_from_user(unsigned int minor, const char *buf, static ssize_t resource_from_user(unsigned int minor, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
ssize_t retval; ssize_t retval;
...@@ -293,7 +294,7 @@ static ssize_t buffer_to_user(unsigned int minor, char __user *buf, ...@@ -293,7 +294,7 @@ static ssize_t buffer_to_user(unsigned int minor, char __user *buf,
return retval; return retval;
} }
static ssize_t buffer_from_user(unsigned int minor, const char *buf, static ssize_t buffer_from_user(unsigned int minor, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
void *image_ptr; void *image_ptr;
...@@ -312,7 +313,7 @@ static ssize_t buffer_from_user(unsigned int minor, const char *buf, ...@@ -312,7 +313,7 @@ static ssize_t buffer_from_user(unsigned int minor, const char *buf,
return retval; return retval;
} }
static ssize_t vme_user_read(struct file *file, char *buf, size_t count, static ssize_t vme_user_read(struct file *file, char __user *buf, size_t count,
loff_t *ppos) loff_t *ppos)
{ {
unsigned int minor = MINOR(file->f_dentry->d_inode->i_rdev); unsigned int minor = MINOR(file->f_dentry->d_inode->i_rdev);
...@@ -356,8 +357,8 @@ static ssize_t vme_user_read(struct file *file, char *buf, size_t count, ...@@ -356,8 +357,8 @@ static ssize_t vme_user_read(struct file *file, char *buf, size_t count,
return retval; return retval;
} }
static ssize_t vme_user_write(struct file *file, const char *buf, size_t count, static ssize_t vme_user_write(struct file *file, const char __user *buf,
loff_t *ppos) size_t count, loff_t *ppos)
{ {
unsigned int minor = MINOR(file->f_dentry->d_inode->i_rdev); unsigned int minor = MINOR(file->f_dentry->d_inode->i_rdev);
ssize_t retval; ssize_t retval;
...@@ -455,6 +456,7 @@ static int vme_user_ioctl(struct inode *inode, struct file *file, ...@@ -455,6 +456,7 @@ static int vme_user_ioctl(struct inode *inode, struct file *file,
unsigned int minor = MINOR(inode->i_rdev); unsigned int minor = MINOR(inode->i_rdev);
int retval; int retval;
dma_addr_t pci_addr; dma_addr_t pci_addr;
void __user *argp = (void __user *)arg;
statistics.ioctls++; statistics.ioctls++;
...@@ -474,7 +476,7 @@ static int vme_user_ioctl(struct inode *inode, struct file *file, ...@@ -474,7 +476,7 @@ static int vme_user_ioctl(struct inode *inode, struct file *file,
&master.size, &master.aspace, &master.size, &master.aspace,
&master.cycle, &master.dwidth); &master.cycle, &master.dwidth);
copied = copy_to_user((char *)arg, &master, copied = copy_to_user(argp, &master,
sizeof(struct vme_master)); sizeof(struct vme_master));
if (copied != 0) { if (copied != 0) {
printk(KERN_WARNING "Partial copy to " printk(KERN_WARNING "Partial copy to "
...@@ -487,8 +489,7 @@ static int vme_user_ioctl(struct inode *inode, struct file *file, ...@@ -487,8 +489,7 @@ static int vme_user_ioctl(struct inode *inode, struct file *file,
case VME_SET_MASTER: case VME_SET_MASTER:
copied = copy_from_user(&master, (char *)arg, copied = copy_from_user(&master, argp, sizeof(master));
sizeof(master));
if (copied != 0) { if (copied != 0) {
printk(KERN_WARNING "Partial copy from " printk(KERN_WARNING "Partial copy from "
"userspace\n"); "userspace\n");
...@@ -518,7 +519,7 @@ static int vme_user_ioctl(struct inode *inode, struct file *file, ...@@ -518,7 +519,7 @@ static int vme_user_ioctl(struct inode *inode, struct file *file,
&slave.size, &pci_addr, &slave.aspace, &slave.size, &pci_addr, &slave.aspace,
&slave.cycle); &slave.cycle);
copied = copy_to_user((char *)arg, &slave, copied = copy_to_user(argp, &slave,
sizeof(struct vme_slave)); sizeof(struct vme_slave));
if (copied != 0) { if (copied != 0) {
printk(KERN_WARNING "Partial copy to " printk(KERN_WARNING "Partial copy to "
...@@ -531,8 +532,7 @@ static int vme_user_ioctl(struct inode *inode, struct file *file, ...@@ -531,8 +532,7 @@ static int vme_user_ioctl(struct inode *inode, struct file *file,
case VME_SET_SLAVE: case VME_SET_SLAVE:
copied = copy_from_user(&slave, (char *)arg, copied = copy_from_user(&slave, argp, sizeof(slave));
sizeof(slave));
if (copied != 0) { if (copied != 0) {
printk(KERN_WARNING "Partial copy from " printk(KERN_WARNING "Partial copy from "
"userspace\n"); "userspace\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment