struct xfs_attrlist             *alist;
        int                             error;
 
+       if (bufsize < sizeof(struct xfs_attrlist) ||
+           bufsize > XFS_XATTR_LIST_MAX)
+               return -EINVAL;
+
+       /*
+        * Reject flags, only allow namespaces.
+        */
+       if (flags & ~(ATTR_ROOT | ATTR_SECURE))
+               return -EINVAL;
+       if (flags == (ATTR_ROOT | ATTR_SECURE))
+               return -EINVAL;
+
        /*
         * Validate the cursor.
         */
                return -EPERM;
        if (copy_from_user(&al_hreq, arg, sizeof(xfs_fsop_attrlist_handlereq_t)))
                return -EFAULT;
-       if (al_hreq.buflen < sizeof(struct xfs_attrlist) ||
-           al_hreq.buflen > XFS_XATTR_LIST_MAX)
-               return -EINVAL;
-
-       /*
-        * Reject flags, only allow namespaces.
-        */
-       if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE))
-               return -EINVAL;
-       if (al_hreq.flags == (ATTR_ROOT | ATTR_SECURE))
-               return -EINVAL;
 
        dentry = xfs_handlereq_to_dentry(parfilp, &al_hreq.hreq);
        if (IS_ERR(dentry))
 
        if (copy_from_user(&al_hreq, arg,
                           sizeof(compat_xfs_fsop_attrlist_handlereq_t)))
                return -EFAULT;
-       if (al_hreq.buflen < sizeof(struct xfs_attrlist) ||
-           al_hreq.buflen > XFS_XATTR_LIST_MAX)
-               return -EINVAL;
-
-       /*
-        * Reject flags, only allow namespaces.
-        */
-       if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE))
-               return -EINVAL;
-       if (al_hreq.flags == (ATTR_ROOT | ATTR_SECURE))
-               return -EINVAL;
 
        dentry = xfs_compat_handlereq_to_dentry(parfilp, &al_hreq.hreq);
        if (IS_ERR(dentry))