]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/compat.c
USB: set default y for CONFIG_USB_DEVICE_CLASS
[linux-2.6-omap-h63xx.git] / fs / compat.c
index 7b21b0a82596f77ed36d844e67d35f1e32934e9a..4db6216e5266a590b0330ff4c8c2868eb84c1013 100644 (file)
@@ -1544,9 +1544,10 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp,
        compat_ulong_t __user *outp, compat_ulong_t __user *exp, s64 *timeout)
 {
        fd_set_bits fds;
-       char *bits;
+       void *bits;
        int size, max_fds, ret = -EINVAL;
        struct fdtable *fdt;
+       long stack_fds[SELECT_STACK_ALLOC/sizeof(long)];
 
        if (n < 0)
                goto out_nofds;
@@ -1564,11 +1565,14 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp,
         * since we used fdset we need to allocate memory in units of
         * long-words.
         */
-       ret = -ENOMEM;
        size = FDS_BYTES(n);
-       bits = kmalloc(6 * size, GFP_KERNEL);
-       if (!bits)
-               goto out_nofds;
+       bits = stack_fds;
+       if (size > sizeof(stack_fds) / 6) {
+               bits = kmalloc(6 * size, GFP_KERNEL);
+               ret = -ENOMEM;
+               if (!bits)
+                       goto out_nofds;
+       }
        fds.in      = (unsigned long *)  bits;
        fds.out     = (unsigned long *) (bits +   size);
        fds.ex      = (unsigned long *) (bits + 2*size);
@@ -1600,7 +1604,8 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp,
            compat_set_fd_set(n, exp, fds.res_ex))
                ret = -EFAULT;
 out:
-       kfree(bits);
+       if (bits != stack_fds)
+               kfree(bits);
 out_nofds:
        return ret;
 }
@@ -2230,21 +2235,16 @@ asmlinkage long compat_sys_signalfd(int ufd,
 asmlinkage long compat_sys_timerfd(int ufd, int clockid, int flags,
                                   const struct compat_itimerspec __user *utmr)
 {
-       long res;
        struct itimerspec t;
        struct itimerspec __user *ut;
 
-       res = -EFAULT;
        if (get_compat_itimerspec(&t, utmr))
-               goto err_exit;
+               return -EFAULT;
        ut = compat_alloc_user_space(sizeof(*ut));
-       if (copy_to_user(ut, &t, sizeof(t)) )
-               goto err_exit;
+       if (copy_to_user(ut, &t, sizeof(t)))
+               return -EFAULT;
 
-       res = sys_timerfd(ufd, clockid, flags, ut);
-err_exit:
-       return res;
+       return sys_timerfd(ufd, clockid, flags, ut);
 }
 
 #endif /* CONFIG_TIMERFD */
-