ALSA: es1688: add pedantic range checks
[safe/jmp/linux-2.6] / fs / nfsd / nfs4acl.c
index 4adb5ee..e480526 100644 (file)
@@ -1,6 +1,4 @@
 /*
- *  fs/nfs4acl/acl.c
- *
  *  Common NFSv4 ACL handling code.
  *
  *  Copyright (c) 2002, 2003 The Regents of the University of Michigan.
  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <linux/string.h>
 #include <linux/slab.h>
-#include <linux/list.h>
-#include <linux/types.h>
-#include <linux/fs.h>
-#include <linux/module.h>
 #include <linux/nfs_fs.h>
-#include <linux/posix_acl.h>
-#include <linux/nfs4.h>
 #include <linux/nfs4_acl.h>
 
 
@@ -321,7 +312,7 @@ _posix_to_nfsv4_one(struct posix_acl *pacl, struct nfs4_acl *acl,
        deny = ~pas.group & pas.other;
        if (deny) {
                ace->type = NFS4_ACE_ACCESS_DENIED_ACE_TYPE;
-               ace->flag = eflag | NFS4_ACE_IDENTIFIER_GROUP;
+               ace->flag = eflag;
                ace->access_mask = deny_mask_from_posix(deny, flags);
                ace->whotype = NFS4_ACL_WHO_GROUP;
                ace++;
@@ -335,7 +326,7 @@ _posix_to_nfsv4_one(struct posix_acl *pacl, struct nfs4_acl *acl,
                if (deny) {
                        ace->type = NFS4_ACE_ACCESS_DENIED_ACE_TYPE;
                        ace->flag = eflag | NFS4_ACE_IDENTIFIER_GROUP;
-                       ace->access_mask = mask_from_posix(deny, flags);
+                       ace->access_mask = deny_mask_from_posix(deny, flags);
                        ace->whotype = NFS4_ACL_WHO_NAMED;
                        ace->who = pa->e_id;
                        ace++;
@@ -389,7 +380,7 @@ sort_pacl(struct posix_acl *pacl)
        sort_pacl_range(pacl, 1, i-1);
 
        BUG_ON(pacl->a_entries[i].e_tag != ACL_GROUP_OBJ);
-       j = i++;
+       j = ++i;
        while (pacl->a_entries[j].e_tag == ACL_GROUP)
                j++;
        sort_pacl_range(pacl, i, j-1);
@@ -443,7 +434,7 @@ init_state(struct posix_acl_state *state, int cnt)
         * enough space for either:
         */
        alloc = sizeof(struct posix_ace_state_array)
-               + cnt*sizeof(struct posix_ace_state);
+               + cnt*sizeof(struct posix_user_ace_state);
        state->users = kzalloc(alloc, GFP_KERNEL);
        if (!state->users)
                return -ENOMEM;
@@ -737,13 +728,16 @@ int nfs4_acl_nfsv4_to_posix(struct nfs4_acl *acl, struct posix_acl **pacl,
        *pacl = posix_state_to_acl(&effective_acl_state, flags);
        if (IS_ERR(*pacl)) {
                ret = PTR_ERR(*pacl);
+               *pacl = NULL;
                goto out_dstate;
        }
        *dpacl = posix_state_to_acl(&default_acl_state,
                                                flags | NFS4_ACL_TYPE_DEFAULT);
        if (IS_ERR(*dpacl)) {
                ret = PTR_ERR(*dpacl);
+               *dpacl = NULL;
                posix_acl_release(*pacl);
+               *pacl = NULL;
                goto out_dstate;
        }
        sort_pacl(*pacl);