Skip to content

Commit 00035be

Browse files
author
Al Viro
committed
comedi: lift copy_from_user() into callers of __comedi_get_user_cmd()
Signed-off-by: Al Viro <[email protected]>
1 parent b8d47d8 commit 00035be

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

drivers/staging/comedi/comedi_fops.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,17 +1649,11 @@ static int do_insn_ioctl(struct comedi_device *dev,
16491649
}
16501650

16511651
static int __comedi_get_user_cmd(struct comedi_device *dev,
1652-
struct comedi_cmd __user *arg,
16531652
struct comedi_cmd *cmd)
16541653
{
16551654
struct comedi_subdevice *s;
16561655

16571656
lockdep_assert_held(&dev->mutex);
1658-
if (copy_from_user(cmd, arg, sizeof(*cmd))) {
1659-
dev_dbg(dev->class_dev, "bad cmd address\n");
1660-
return -EFAULT;
1661-
}
1662-
16631657
if (cmd->subdev >= dev->n_subdevices) {
16641658
dev_dbg(dev->class_dev, "%d no such subdevice\n", cmd->subdev);
16651659
return -ENODEV;
@@ -1757,8 +1751,13 @@ static int do_cmd_ioctl(struct comedi_device *dev,
17571751

17581752
lockdep_assert_held(&dev->mutex);
17591753

1754+
if (copy_from_user(&cmd, arg, sizeof(cmd))) {
1755+
dev_dbg(dev->class_dev, "bad cmd address\n");
1756+
return -EFAULT;
1757+
}
1758+
17601759
/* get the user's cmd and do some simple validation */
1761-
ret = __comedi_get_user_cmd(dev, arg, &cmd);
1760+
ret = __comedi_get_user_cmd(dev, &cmd);
17621761
if (ret)
17631762
return ret;
17641763

@@ -1866,8 +1865,13 @@ static int do_cmdtest_ioctl(struct comedi_device *dev,
18661865

18671866
lockdep_assert_held(&dev->mutex);
18681867

1868+
if (copy_from_user(&cmd, arg, sizeof(cmd))) {
1869+
dev_dbg(dev->class_dev, "bad cmd address\n");
1870+
return -EFAULT;
1871+
}
1872+
18691873
/* get the user's cmd and do some simple validation */
1870-
ret = __comedi_get_user_cmd(dev, arg, &cmd);
1874+
ret = __comedi_get_user_cmd(dev, &cmd);
18711875
if (ret)
18721876
return ret;
18731877

0 commit comments

Comments
 (0)