Merge branch 'fix/hda' into for-linus
[linux-2.6-block.git] / fs / hugetlbfs / inode.c
index c1462d43e7217de23f046852d9fd466af0617e65..cb88dac8ccaae6f43dfc25edbcaa202fa0cb26cb 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/dnotify.h>
 #include <linux/statfs.h>
 #include <linux/security.h>
+#include <linux/ima.h>
 
 #include <asm/uaccess.h>
 
@@ -934,26 +935,28 @@ static int can_do_hugetlb_shm(void)
        return capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group);
 }
 
-struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag)
+struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag,
+                                               struct user_struct **user)
 {
        int error = -ENOMEM;
-       int unlock_shm = 0;
        struct file *file;
        struct inode *inode;
        struct dentry *dentry, *root;
        struct qstr quick_string;
-       struct user_struct *user = current_user();
 
+       *user = NULL;
        if (!hugetlbfs_vfsmount)
                return ERR_PTR(-ENOENT);
 
        if (!can_do_hugetlb_shm()) {
-               if (user_shm_lock(size, user)) {
-                       unlock_shm = 1;
+               *user = current_user();
+               if (user_shm_lock(size, *user)) {
                        WARN_ONCE(1,
                          "Using mlock ulimits for SHM_HUGETLB deprecated\n");
-               } else
+               } else {
+                       *user = NULL;
                        return ERR_PTR(-EPERM);
+               }
        }
 
        root = hugetlbfs_vfsmount->mnt_root;
@@ -986,6 +989,7 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag)
                        &hugetlbfs_file_operations);
        if (!file)
                goto out_dentry; /* inode is already attached */
+       ima_counts_get(file);
 
        return file;
 
@@ -994,8 +998,10 @@ out_inode:
 out_dentry:
        dput(dentry);
 out_shm_unlock:
-       if (unlock_shm)
-               user_shm_unlock(size, user);
+       if (*user) {
+               user_shm_unlock(size, *user);
+               *user = NULL;
+       }
        return ERR_PTR(error);
 }