diff options
author | Harshal Chaudhari <harshalchau04@gmail.com> | 2020-11-01 20:09:49 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-11-03 12:11:48 +0300 |
commit | c78c95f919539cad0308e7de0d5d0d656e4a8e98 (patch) | |
tree | fd295f2663d0a6ee12421e8216cfc7f12df97df6 /drivers/misc/xilinx_sdfec.c | |
parent | 33fcc5491897504856783335102142676dbee817 (diff) | |
download | linux-c78c95f919539cad0308e7de0d5d0d656e4a8e98.tar.xz |
misc: xilinx-sdfec: remove check for ioctl cmd and argument.
if (_IOC_TYPE(cmd) != PP_IOCTL)
return -ENOTTY;
Invalid ioctl command check normally performs by “default” case.
if (_IOC_DIR(cmd) != _IOC_NONE) {
argp = (void __user *)arg;
if (!argp)
return -EINVAL; }
And for checking ioctl arguments, copy_from_user()/copy_to_user()
checks are enough.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Harshal Chaudhari <harshalchau04@gmail.com>
Link: https://lore.kernel.org/r/20201101170949.18616-1-harshalchau04@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/xilinx_sdfec.c')
-rw-r--r-- | drivers/misc/xilinx_sdfec.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/drivers/misc/xilinx_sdfec.c b/drivers/misc/xilinx_sdfec.c index 6f252793dceb..23c8448a9c3b 100644 --- a/drivers/misc/xilinx_sdfec.c +++ b/drivers/misc/xilinx_sdfec.c @@ -944,8 +944,8 @@ static long xsdfec_dev_ioctl(struct file *fptr, unsigned int cmd, unsigned long data) { struct xsdfec_dev *xsdfec; - void __user *arg = NULL; - int rval = -EINVAL; + void __user *arg = (void __user *)data; + int rval; xsdfec = container_of(fptr->private_data, struct xsdfec_dev, miscdev); @@ -956,16 +956,6 @@ static long xsdfec_dev_ioctl(struct file *fptr, unsigned int cmd, return -EPERM; } - if (_IOC_TYPE(cmd) != XSDFEC_MAGIC) - return -ENOTTY; - - /* check if ioctl argument is present and valid */ - if (_IOC_DIR(cmd) != _IOC_NONE) { - arg = (void __user *)data; - if (!arg) - return rval; - } - switch (cmd) { case XSDFEC_START_DEV: rval = xsdfec_start(xsdfec); @@ -1010,7 +1000,7 @@ static long xsdfec_dev_ioctl(struct file *fptr, unsigned int cmd, rval = xsdfec_is_active(xsdfec, (bool __user *)arg); break; default: - /* Should not get here */ + rval = -ENOTTY; break; } return rval; |