]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/md/dm-ioctl.c
md: fix formatting error in /proc/mdstat
[linux-2.6-omap-h63xx.git] / drivers / md / dm-ioctl.c
index 4aa1f78b78f0521af0704e132dda213b8b7b1b51..b262c0042de3f79394d7ff46c61e36b68da29e48 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/slab.h>
 #include <linux/dm-ioctl.h>
 #include <linux/hdreg.h>
+#include <linux/compat.h>
 
 #include <asm/uaccess.h>
 
@@ -1350,10 +1351,10 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param)
 {
        struct dm_ioctl tmp, *dmi;
 
-       if (copy_from_user(&tmp, user, sizeof(tmp)))
+       if (copy_from_user(&tmp, user, sizeof(tmp) - sizeof(tmp.data)))
                return -EFAULT;
 
-       if (tmp.data_size < sizeof(tmp))
+       if (tmp.data_size < (sizeof(tmp) - sizeof(tmp.data)))
                return -EINVAL;
 
        dmi = vmalloc(tmp.data_size);
@@ -1401,7 +1402,7 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user)
 {
        int r = 0;
        unsigned int cmd;
-       struct dm_ioctl *param;
+       struct dm_ioctl *uninitialized_var(param);
        ioctl_fn fn = NULL;
        size_t param_size;
 
@@ -1474,8 +1475,18 @@ static long dm_ctl_ioctl(struct file *file, uint command, ulong u)
        return (long)ctl_ioctl(command, (struct dm_ioctl __user *)u);
 }
 
+#ifdef CONFIG_COMPAT
+static long dm_compat_ctl_ioctl(struct file *file, uint command, ulong u)
+{
+       return (long)dm_ctl_ioctl(file, command, (ulong) compat_ptr(u));
+}
+#else
+#define dm_compat_ctl_ioctl NULL
+#endif
+
 static const struct file_operations _ctl_fops = {
        .unlocked_ioctl  = dm_ctl_ioctl,
+       .compat_ioctl = dm_compat_ctl_ioctl,
        .owner   = THIS_MODULE,
 };