patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / net / atm / resources.c
index a72dc2d..58de2ac 100644 (file)
@@ -180,7 +180,7 @@ static void subtract_aal_stats(struct k_atm_aal_stats *from,
 }
 
 
-static int fetch_stats(struct atm_dev *dev, struct atm_dev_stats *arg, int zero)
+static int fetch_stats(struct atm_dev *dev, struct atm_dev_stats __user *arg, int zero)
 {
        struct atm_dev_stats tmp;
        int error = 0;
@@ -199,19 +199,20 @@ static int fetch_stats(struct atm_dev *dev, struct atm_dev_stats *arg, int zero)
 }
 
 
-int atm_dev_ioctl(unsigned int cmd, unsigned long arg)
+int atm_dev_ioctl(unsigned int cmd, void __user *arg)
 {
-       void *buf;
+       void __user *buf;
        int error, len, number, size = 0;
        struct atm_dev *dev;
        struct list_head *p;
        int *tmp_buf, *tmp_p;
-
+       struct atm_iobuf __user *iobuf = arg;
+       struct atmif_sioc __user *sioc = arg;
        switch (cmd) {
                case ATM_GETNAMES:
-                       if (get_user(buf, &((struct atm_iobuf *) arg)->buffer))
+                       if (get_user(buf, &iobuf->buffer))
                                return -EFAULT;
-                       if (get_user(len, &((struct atm_iobuf *) arg)->length))
+                       if (get_user(len, &iobuf->length))
                                return -EFAULT;
                        spin_lock(&atm_dev_lock);
                        list_for_each(p, &atm_devs)
@@ -232,7 +233,7 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg)
                        }
                        spin_unlock(&atm_dev_lock);
                        error = ((copy_to_user(buf, tmp_buf, size)) ||
-                                       put_user(size, &((struct atm_iobuf *) arg)->length))
+                                       put_user(size, &iobuf->length))
                                                ? -EFAULT : 0;
                        kfree(tmp_buf);
                        return error;
@@ -240,11 +241,11 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg)
                        break;
        }
 
-       if (get_user(buf, &((struct atmif_sioc *) arg)->arg))
+       if (get_user(buf, &sioc->arg))
                return -EFAULT;
-       if (get_user(len, &((struct atmif_sioc *) arg)->length))
+       if (get_user(len, &sioc->length))
                return -EFAULT;
-       if (get_user(number, &((struct atmif_sioc *) arg)->number))
+       if (get_user(number, &sioc->number))
                return -EFAULT;
 
        if (!(dev = atm_dev_lookup(number)))
@@ -351,7 +352,7 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg)
                        size = error;
                        /* may return 0, but later on size == 0 means "don't
                           write the length" */
-                       error = put_user(size, &((struct atmif_sioc *) arg)->length)
+                       error = put_user(size, &sioc->length)
                                ? -EFAULT : 0;
                        goto done;
                case ATM_SETLOOP:
@@ -385,7 +386,7 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg)
        }
        
        if (size)
-               error = put_user(size, &((struct atmif_sioc *) arg)->length)
+               error = put_user(size, &sioc->length)
                        ? -EFAULT : 0;
        else
                error = 0;