diff options
author | H Hartley Sweeten <hartleys@visionengravers.com> | 2012-09-18 14:43:13 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-09-19 04:36:45 -0400 |
commit | f8348677b1fffff801d5323db7ccadfdb2b290d0 (patch) | |
tree | ecd1c0e785ddf66eb58ce2368c1c82a24f29a4c5 | |
parent | 88bc0574ba6a7cb38f4b5ea2f0e5ed9fe4ab7e27 (diff) |
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: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Acked-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/comedi/comedi_fops.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index a240e661c7b7..df627c8223d5 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c | |||
@@ -1283,77 +1283,77 @@ cleanup: | |||
1283 | static int do_cmdtest_ioctl(struct comedi_device *dev, | 1283 | static int do_cmdtest_ioctl(struct comedi_device *dev, |
1284 | struct comedi_cmd __user *arg, void *file) | 1284 | struct comedi_cmd __user *arg, void *file) |
1285 | { | 1285 | { |
1286 | struct comedi_cmd user_cmd; | 1286 | struct comedi_cmd cmd; |
1287 | struct comedi_subdevice *s; | 1287 | struct comedi_subdevice *s; |
1288 | int ret = 0; | 1288 | int ret = 0; |
1289 | unsigned int *chanlist = NULL; | 1289 | unsigned int *chanlist = NULL; |
1290 | unsigned int __user *chanlist_saver = NULL; | 1290 | unsigned int __user *chanlist_saver = NULL; |
1291 | 1291 | ||
1292 | if (copy_from_user(&user_cmd, arg, sizeof(struct comedi_cmd))) { | 1292 | if (copy_from_user(&cmd, arg, sizeof(struct comedi_cmd))) { |
1293 | DPRINTK("bad cmd address\n"); | 1293 | DPRINTK("bad cmd address\n"); |
1294 | return -EFAULT; | 1294 | return -EFAULT; |
1295 | } | 1295 | } |
1296 | /* save user's chanlist pointer so it can be restored later */ | 1296 | /* save user's chanlist pointer so it can be restored later */ |
1297 | chanlist_saver = user_cmd.chanlist; | 1297 | chanlist_saver = cmd.chanlist; |
1298 | 1298 | ||
1299 | if (user_cmd.subdev >= dev->n_subdevices) { | 1299 | if (cmd.subdev >= dev->n_subdevices) { |
1300 | DPRINTK("%d no such subdevice\n", user_cmd.subdev); | 1300 | DPRINTK("%d no such subdevice\n", cmd.subdev); |
1301 | return -ENODEV; | 1301 | return -ENODEV; |
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | s = &dev->subdevices[user_cmd.subdev]; | 1304 | s = &dev->subdevices[cmd.subdev]; |
1305 | if (s->type == COMEDI_SUBD_UNUSED) { | 1305 | if (s->type == COMEDI_SUBD_UNUSED) { |
1306 | DPRINTK("%d not valid subdevice\n", user_cmd.subdev); | 1306 | DPRINTK("%d not valid subdevice\n", cmd.subdev); |
1307 | return -EIO; | 1307 | return -EIO; |
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | if (!s->do_cmd || !s->do_cmdtest) { | 1310 | if (!s->do_cmd || !s->do_cmdtest) { |
1311 | DPRINTK("subdevice %i does not support commands\n", | 1311 | DPRINTK("subdevice %i does not support commands\n", |
1312 | user_cmd.subdev); | 1312 | cmd.subdev); |
1313 | return -EIO; | 1313 | return -EIO; |
1314 | } | 1314 | } |
1315 | 1315 | ||
1316 | /* make sure channel/gain list isn't too long */ | 1316 | /* make sure channel/gain list isn't too long */ |
1317 | if (user_cmd.chanlist_len > s->len_chanlist) { | 1317 | if (cmd.chanlist_len > s->len_chanlist) { |
1318 | DPRINTK("channel/gain list too long %d > %d\n", | 1318 | DPRINTK("channel/gain list too long %d > %d\n", |
1319 | user_cmd.chanlist_len, s->len_chanlist); | 1319 | cmd.chanlist_len, s->len_chanlist); |
1320 | ret = -EINVAL; | 1320 | ret = -EINVAL; |
1321 | goto cleanup; | 1321 | goto cleanup; |
1322 | } | 1322 | } |
1323 | 1323 | ||
1324 | /* load channel/gain list */ | 1324 | /* load channel/gain list */ |
1325 | if (user_cmd.chanlist) { | 1325 | if (cmd.chanlist) { |
1326 | chanlist = | 1326 | chanlist = |
1327 | kmalloc(user_cmd.chanlist_len * sizeof(int), GFP_KERNEL); | 1327 | kmalloc(cmd.chanlist_len * sizeof(int), GFP_KERNEL); |
1328 | if (!chanlist) { | 1328 | if (!chanlist) { |
1329 | DPRINTK("allocation failed\n"); | 1329 | DPRINTK("allocation failed\n"); |
1330 | ret = -ENOMEM; | 1330 | ret = -ENOMEM; |
1331 | goto cleanup; | 1331 | goto cleanup; |
1332 | } | 1332 | } |
1333 | 1333 | ||
1334 | if (copy_from_user(chanlist, user_cmd.chanlist, | 1334 | if (copy_from_user(chanlist, cmd.chanlist, |
1335 | user_cmd.chanlist_len * sizeof(int))) { | 1335 | cmd.chanlist_len * sizeof(int))) { |
1336 | DPRINTK("fault reading chanlist\n"); | 1336 | DPRINTK("fault reading chanlist\n"); |
1337 | ret = -EFAULT; | 1337 | ret = -EFAULT; |
1338 | goto cleanup; | 1338 | goto cleanup; |
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | /* make sure each element in channel/gain list is valid */ | 1341 | /* make sure each element in channel/gain list is valid */ |
1342 | ret = comedi_check_chanlist(s, user_cmd.chanlist_len, chanlist); | 1342 | ret = comedi_check_chanlist(s, cmd.chanlist_len, chanlist); |
1343 | if (ret < 0) { | 1343 | if (ret < 0) { |
1344 | DPRINTK("bad chanlist\n"); | 1344 | DPRINTK("bad chanlist\n"); |
1345 | goto cleanup; | 1345 | goto cleanup; |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | user_cmd.chanlist = chanlist; | 1348 | cmd.chanlist = chanlist; |
1349 | } | 1349 | } |
1350 | 1350 | ||
1351 | ret = s->do_cmdtest(dev, s, &user_cmd); | 1351 | ret = s->do_cmdtest(dev, s, &cmd); |
1352 | 1352 | ||
1353 | /* restore chanlist pointer before copying back */ | 1353 | /* restore chanlist pointer before copying back */ |
1354 | user_cmd.chanlist = chanlist_saver; | 1354 | cmd.chanlist = chanlist_saver; |
1355 | 1355 | ||
1356 | if (copy_to_user(arg, &user_cmd, sizeof(struct comedi_cmd))) { | 1356 | if (copy_to_user(arg, &cmd, sizeof(struct comedi_cmd))) { |
1357 | DPRINTK("bad cmd address\n"); | 1357 | DPRINTK("bad cmd address\n"); |
1358 | ret = -EFAULT; | 1358 | ret = -EFAULT; |
1359 | goto cleanup; | 1359 | goto cleanup; |