compat_ioctl: use correct compat_ptr() translation in drivers
authorArnd Bergmann <arnd@arndb.de>
Tue, 11 Sep 2018 15:28:08 +0000 (17:28 +0200)
committerArnd Bergmann <arnd@arndb.de>
Wed, 23 Oct 2019 15:23:44 +0000 (17:23 +0200)
A handful of drivers all have a trivial wrapper around their ioctl
handler, but don't call the compat_ptr() conversion function at the
moment. In practice this does not matter, since none of them are used
on the s390 architecture and for all other architectures, compat_ptr()
does not do anything, but using the new compat_ptr_ioctl()
helper makes it more correct in theory, and simplifies the code.

I checked that all ioctl handlers in these files are compatible
and take either pointer arguments or no argument.

Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
drivers/misc/cxl/flash.c
drivers/misc/genwqe/card_dev.c
drivers/scsi/megaraid/megaraid_mm.c
drivers/usb/gadget/function/f_fs.c

index 4d6836f194898041765fed9d8b0da46ec9a7758f..cb9cca35a226329a5f88b78610577179cae49639 100644 (file)
@@ -473,12 +473,6 @@ static long device_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                return -EINVAL;
 }
 
-static long device_compat_ioctl(struct file *file, unsigned int cmd,
-                               unsigned long arg)
-{
-       return device_ioctl(file, cmd, arg);
-}
-
 static int device_close(struct inode *inode, struct file *file)
 {
        struct cxl *adapter = file->private_data;
@@ -514,7 +508,7 @@ static const struct file_operations fops = {
        .owner          = THIS_MODULE,
        .open           = device_open,
        .unlocked_ioctl = device_ioctl,
-       .compat_ioctl   = device_compat_ioctl,
+       .compat_ioctl   = compat_ptr_ioctl,
        .release        = device_close,
 };
 
index 0e34c0568fed1adf910c82928478fc17ae8436e9..040a0bda312549ea39dd8bc29028bf9949ebc403 100644 (file)
@@ -1215,34 +1215,13 @@ static long genwqe_ioctl(struct file *filp, unsigned int cmd,
        return rc;
 }
 
-#if defined(CONFIG_COMPAT)
-/**
- * genwqe_compat_ioctl() - Compatibility ioctl
- *
- * Called whenever a 32-bit process running under a 64-bit kernel
- * performs an ioctl on /dev/genwqe<n>_card.
- *
- * @filp:        file pointer.
- * @cmd:         command.
- * @arg:         user argument.
- * Return:       zero on success or negative number on failure.
- */
-static long genwqe_compat_ioctl(struct file *filp, unsigned int cmd,
-                               unsigned long arg)
-{
-       return genwqe_ioctl(filp, cmd, arg);
-}
-#endif /* defined(CONFIG_COMPAT) */
-
 static const struct file_operations genwqe_fops = {
        .owner          = THIS_MODULE,
        .open           = genwqe_open,
        .fasync         = genwqe_fasync,
        .mmap           = genwqe_mmap,
        .unlocked_ioctl = genwqe_ioctl,
-#if defined(CONFIG_COMPAT)
-       .compat_ioctl   = genwqe_compat_ioctl,
-#endif
+       .compat_ioctl   = compat_ptr_ioctl,
        .release        = genwqe_release,
 };
 
index 59cca898f0882692ca45387a2a5c0b8cb688fc5a..e83163c66884508278ba28a400a2e0d6f79e36a4 100644 (file)
@@ -41,10 +41,6 @@ static int mraid_mm_setup_dma_pools(mraid_mmadp_t *);
 static void mraid_mm_free_adp_resources(mraid_mmadp_t *);
 static void mraid_mm_teardown_dma_pools(mraid_mmadp_t *);
 
-#ifdef CONFIG_COMPAT
-static long mraid_mm_compat_ioctl(struct file *, unsigned int, unsigned long);
-#endif
-
 MODULE_AUTHOR("LSI Logic Corporation");
 MODULE_DESCRIPTION("LSI Logic Management Module");
 MODULE_LICENSE("GPL");
@@ -68,9 +64,7 @@ static wait_queue_head_t wait_q;
 static const struct file_operations lsi_fops = {
        .open   = mraid_mm_open,
        .unlocked_ioctl = mraid_mm_unlocked_ioctl,
-#ifdef CONFIG_COMPAT
-       .compat_ioctl = mraid_mm_compat_ioctl,
-#endif
+       .compat_ioctl = compat_ptr_ioctl,
        .owner  = THIS_MODULE,
        .llseek = noop_llseek,
 };
@@ -224,7 +218,6 @@ mraid_mm_unlocked_ioctl(struct file *filep, unsigned int cmd,
 {
        int err;
 
-       /* inconsistent: mraid_mm_compat_ioctl doesn't take the BKL */
        mutex_lock(&mraid_mm_mutex);
        err = mraid_mm_ioctl(filep, cmd, arg);
        mutex_unlock(&mraid_mm_mutex);
@@ -1228,25 +1221,6 @@ mraid_mm_init(void)
 }
 
 
-#ifdef CONFIG_COMPAT
-/**
- * mraid_mm_compat_ioctl       - 32bit to 64bit ioctl conversion routine
- * @filep      : file operations pointer (ignored)
- * @cmd                : ioctl command
- * @arg                : user ioctl packet
- */
-static long
-mraid_mm_compat_ioctl(struct file *filep, unsigned int cmd,
-                     unsigned long arg)
-{
-       int err;
-
-       err = mraid_mm_ioctl(filep, cmd, arg);
-
-       return err;
-}
-#endif
-
 /**
  * mraid_mm_exit       - Module exit point
  */
index 59d9d512dcdacef45f0c8a5f51162ea8b450e105..ce1d0235969c369ce02bd2c5fa6dfbfb36a8a549 100644 (file)
@@ -1352,14 +1352,6 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code,
        return ret;
 }
 
-#ifdef CONFIG_COMPAT
-static long ffs_epfile_compat_ioctl(struct file *file, unsigned code,
-               unsigned long value)
-{
-       return ffs_epfile_ioctl(file, code, value);
-}
-#endif
-
 static const struct file_operations ffs_epfile_operations = {
        .llseek =       no_llseek,
 
@@ -1368,9 +1360,7 @@ static const struct file_operations ffs_epfile_operations = {
        .read_iter =    ffs_epfile_read_iter,
        .release =      ffs_epfile_release,
        .unlocked_ioctl =       ffs_epfile_ioctl,
-#ifdef CONFIG_COMPAT
-       .compat_ioctl = ffs_epfile_compat_ioctl,
-#endif
+       .compat_ioctl = compat_ptr_ioctl,
 };