[PATCH 3/3] staging: comedi: add __user tag to chanlist
Ian Abbott
abbotti at mev.co.uk
Mon Sep 24 12:34:14 UTC 2012
This reverts "staging: comedi: comedi.h: remove __user tag from
chanlist" by H Hartley Sweeten on 2012-09-18 (committed by Greg
Kroah-Hartman on Wed Sep 19 09:36:44 2012 +0100), and also removes a
couple of `__user` casts that are now unnecessary and a couple of
`__force` casts that are now wrong.
The `chanlist` member of `struct comedi_cmd` is used by the `COMEDI_CMD`
and `COMEDI_CMDTEST` ioctls where it points to a channel list in user
memory (but it may be `NULL` for the `COMEDI_CMDTEST` ioctl).
Previously, the `chanlist` member pointed to a kernel copy of the
channel list in other contexts, but that is no longer the case.
Signed-off-by: Ian Abbott <abbotti at mev.co.uk>
---
v2: Reordered patch sequence. Combined original patches 1 and 2 to
avoid introducing sparse warnings.
---
drivers/staging/comedi/comedi.h | 2 +-
drivers/staging/comedi/comedi_fops.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h
index 133f013..76cdb2c 100644
--- a/drivers/staging/comedi/comedi.h
+++ b/drivers/staging/comedi/comedi.h
@@ -365,7 +365,7 @@ struct comedi_cmd {
unsigned int stop_src;
unsigned int stop_arg;
- unsigned int *chanlist; /* channel/range list */
+ unsigned int __user *chanlist; /* channel/range list */
unsigned int chanlist_len;
short __user *data; /* data list, size depends on subd flags */
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 41dbe68..9433aae 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1145,7 +1145,7 @@ static int do_cmd_ioctl(struct comedi_device *dev,
return -EFAULT;
}
/* save user's chanlist pointer so it can be restored later */
- user_chanlist = (unsigned int __user *)cmd.chanlist;
+ user_chanlist = cmd.chanlist;
if (cmd.subdev >= dev->n_subdevices) {
DPRINTK("%d no such subdevice\n", cmd.subdev);
@@ -1229,7 +1229,7 @@ static int do_cmd_ioctl(struct comedi_device *dev,
DPRINTK("test returned %d\n", ret);
cmd = async->cmd;
/* restore chanlist pointer before copying back */
- cmd.chanlist = (unsigned int __force *)user_chanlist;
+ cmd.chanlist = user_chanlist;
cmd.data = NULL;
if (copy_to_user(arg, &cmd, sizeof(struct comedi_cmd))) {
DPRINTK("fault writing cmd\n");
@@ -1295,7 +1295,7 @@ static int do_cmdtest_ioctl(struct comedi_device *dev,
return -EFAULT;
}
/* save user's chanlist pointer so it can be restored later */
- user_chanlist = (unsigned int __user *)cmd.chanlist;
+ user_chanlist = cmd.chanlist;
if (cmd.subdev >= dev->n_subdevices) {
DPRINTK("%d no such subdevice\n", cmd.subdev);
@@ -1351,7 +1351,7 @@ static int do_cmdtest_ioctl(struct comedi_device *dev,
ret = s->do_cmdtest(dev, s, &cmd, chanlist);
/* restore chanlist pointer before copying back */
- cmd.chanlist = (unsigned int __force *)user_chanlist;
+ cmd.chanlist = user_chanlist;
if (copy_to_user(arg, &cmd, sizeof(struct comedi_cmd))) {
DPRINTK("bad cmd address\n");
ret = -EFAULT;
--
1.7.12
More information about the devel
mailing list