Commit f8348677 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: comedi_fops: rename user_cmd in do_cmdtest_ioctl

This local variable is used to hold the comedi_cmd that is passed
to the kernel as the argument to the COMEDI_CMDTEST ioctl. Its filled
in with a copy_from_user() call. The name 'user_cmd' is a bit
confusing since it's actually kernel data.

Rename the local variable to 'cmd' to avoid the confusion.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Acked-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 88bc0574
...@@ -1283,77 +1283,77 @@ static int do_cmd_ioctl(struct comedi_device *dev, ...@@ -1283,77 +1283,77 @@ static int do_cmd_ioctl(struct comedi_device *dev,
static int do_cmdtest_ioctl(struct comedi_device *dev, static int do_cmdtest_ioctl(struct comedi_device *dev,
struct comedi_cmd __user *arg, void *file) struct comedi_cmd __user *arg, void *file)
{ {
struct comedi_cmd user_cmd; struct comedi_cmd cmd;
struct comedi_subdevice *s; struct comedi_subdevice *s;
int ret = 0; int ret = 0;
unsigned int *chanlist = NULL; unsigned int *chanlist = NULL;
unsigned int __user *chanlist_saver = NULL; unsigned int __user *chanlist_saver = NULL;
if (copy_from_user(&user_cmd, arg, sizeof(struct comedi_cmd))) { if (copy_from_user(&cmd, arg, sizeof(struct comedi_cmd))) {
DPRINTK("bad cmd address\n"); DPRINTK("bad cmd address\n");
return -EFAULT; return -EFAULT;
} }
/* save user's chanlist pointer so it can be restored later */ /* save user's chanlist pointer so it can be restored later */
chanlist_saver = user_cmd.chanlist; chanlist_saver = cmd.chanlist;
if (user_cmd.subdev >= dev->n_subdevices) { if (cmd.subdev >= dev->n_subdevices) {
DPRINTK("%d no such subdevice\n", user_cmd.subdev); DPRINTK("%d no such subdevice\n", cmd.subdev);
return -ENODEV; return -ENODEV;
} }
s = &dev->subdevices[user_cmd.subdev]; s = &dev->subdevices[cmd.subdev];
if (s->type == COMEDI_SUBD_UNUSED) { if (s->type == COMEDI_SUBD_UNUSED) {
DPRINTK("%d not valid subdevice\n", user_cmd.subdev); DPRINTK("%d not valid subdevice\n", cmd.subdev);
return -EIO; return -EIO;
} }
if (!s->do_cmd || !s->do_cmdtest) { if (!s->do_cmd || !s->do_cmdtest) {
DPRINTK("subdevice %i does not support commands\n", DPRINTK("subdevice %i does not support commands\n",
user_cmd.subdev); cmd.subdev);
return -EIO; return -EIO;
} }
/* make sure channel/gain list isn't too long */ /* make sure channel/gain list isn't too long */
if (user_cmd.chanlist_len > s->len_chanlist) { if (cmd.chanlist_len > s->len_chanlist) {
DPRINTK("channel/gain list too long %d > %d\n", DPRINTK("channel/gain list too long %d > %d\n",
user_cmd.chanlist_len, s->len_chanlist); cmd.chanlist_len, s->len_chanlist);
ret = -EINVAL; ret = -EINVAL;
goto cleanup; goto cleanup;
} }
/* load channel/gain list */ /* load channel/gain list */
if (user_cmd.chanlist) { if (cmd.chanlist) {
chanlist = chanlist =
kmalloc(user_cmd.chanlist_len * sizeof(int), GFP_KERNEL); kmalloc(cmd.chanlist_len * sizeof(int), GFP_KERNEL);
if (!chanlist) { if (!chanlist) {
DPRINTK("allocation failed\n"); DPRINTK("allocation failed\n");
ret = -ENOMEM; ret = -ENOMEM;
goto cleanup; goto cleanup;
} }
if (copy_from_user(chanlist, user_cmd.chanlist, if (copy_from_user(chanlist, cmd.chanlist,
user_cmd.chanlist_len * sizeof(int))) { cmd.chanlist_len * sizeof(int))) {
DPRINTK("fault reading chanlist\n"); DPRINTK("fault reading chanlist\n");
ret = -EFAULT; ret = -EFAULT;
goto cleanup; goto cleanup;
} }
/* make sure each element in channel/gain list is valid */ /* make sure each element in channel/gain list is valid */
ret = comedi_check_chanlist(s, user_cmd.chanlist_len, chanlist); ret = comedi_check_chanlist(s, cmd.chanlist_len, chanlist);
if (ret < 0) { if (ret < 0) {
DPRINTK("bad chanlist\n"); DPRINTK("bad chanlist\n");
goto cleanup; goto cleanup;
} }
user_cmd.chanlist = chanlist; cmd.chanlist = chanlist;
} }
ret = s->do_cmdtest(dev, s, &user_cmd); ret = s->do_cmdtest(dev, s, &cmd);
/* restore chanlist pointer before copying back */ /* restore chanlist pointer before copying back */
user_cmd.chanlist = chanlist_saver; cmd.chanlist = chanlist_saver;
if (copy_to_user(arg, &user_cmd, sizeof(struct comedi_cmd))) { if (copy_to_user(arg, &cmd, sizeof(struct comedi_cmd))) {
DPRINTK("bad cmd address\n"); DPRINTK("bad cmd address\n");
ret = -EFAULT; ret = -EFAULT;
goto cleanup; goto cleanup;
......
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