Browse Source

[S390] tape_char: add missing compat_ptr conversion

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Heiko Carstens 15 years ago
parent
commit
c540607978
1 changed files with 15 additions and 3 deletions
  1. 15 3
      drivers/s390/char/tape_char.c

+ 15 - 3
drivers/s390/char/tape_char.c

@@ -18,6 +18,7 @@
 #include <linux/proc_fs.h>
 #include <linux/proc_fs.h>
 #include <linux/mtio.h>
 #include <linux/mtio.h>
 #include <linux/smp_lock.h>
 #include <linux/smp_lock.h>
+#include <linux/compat.h>
 
 
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 
 
@@ -37,8 +38,9 @@ static ssize_t tapechar_write(struct file *, const char __user *, size_t, loff_t
 static int tapechar_open(struct inode *,struct file *);
 static int tapechar_open(struct inode *,struct file *);
 static int tapechar_release(struct inode *,struct file *);
 static int tapechar_release(struct inode *,struct file *);
 static long tapechar_ioctl(struct file *, unsigned int, unsigned long);
 static long tapechar_ioctl(struct file *, unsigned int, unsigned long);
-static long tapechar_compat_ioctl(struct file *, unsigned int,
-			  unsigned long);
+#ifdef CONFIG_COMPAT
+static long tapechar_compat_ioctl(struct file *, unsigned int, unsigned long);
+#endif
 
 
 static const struct file_operations tape_fops =
 static const struct file_operations tape_fops =
 {
 {
@@ -46,7 +48,9 @@ static const struct file_operations tape_fops =
 	.read = tapechar_read,
 	.read = tapechar_read,
 	.write = tapechar_write,
 	.write = tapechar_write,
 	.unlocked_ioctl = tapechar_ioctl,
 	.unlocked_ioctl = tapechar_ioctl,
+#ifdef CONFIG_COMPAT
 	.compat_ioctl = tapechar_compat_ioctl,
 	.compat_ioctl = tapechar_compat_ioctl,
+#endif
 	.open = tapechar_open,
 	.open = tapechar_open,
 	.release = tapechar_release,
 	.release = tapechar_release,
 };
 };
@@ -457,15 +461,22 @@ tapechar_ioctl(struct file *filp, unsigned int no, unsigned long data)
 	return rc;
 	return rc;
 }
 }
 
 
+#ifdef CONFIG_COMPAT
 static long
 static long
 tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data)
 tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data)
 {
 {
 	struct tape_device *device = filp->private_data;
 	struct tape_device *device = filp->private_data;
 	int rval = -ENOIOCTLCMD;
 	int rval = -ENOIOCTLCMD;
+	unsigned long argp;
 
 
+	/* The 'arg' argument of any ioctl function may only be used for
+	 * pointers because of the compat pointer conversion.
+	 * Consider this when adding new ioctls.
+	 */
+	argp = (unsigned long) compat_ptr(data);
 	if (device->discipline->ioctl_fn) {
 	if (device->discipline->ioctl_fn) {
 		mutex_lock(&device->mutex);
 		mutex_lock(&device->mutex);
-		rval = device->discipline->ioctl_fn(device, no, data);
+		rval = device->discipline->ioctl_fn(device, no, argp);
 		mutex_unlock(&device->mutex);
 		mutex_unlock(&device->mutex);
 		if (rval == -EINVAL)
 		if (rval == -EINVAL)
 			rval = -ENOIOCTLCMD;
 			rval = -ENOIOCTLCMD;
@@ -473,6 +484,7 @@ tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data)
 
 
 	return rval;
 	return rval;
 }
 }
+#endif /* CONFIG_COMPAT */
 
 
 /*
 /*
  * Initialize character device frontend.
  * Initialize character device frontend.