]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - drivers/oprofile/oprofilefs.c
fs: Limit sys_mount to only request filesystem modules.
[mirror_ubuntu-zesty-kernel.git] / drivers / oprofile / oprofilefs.c
index 849357c1045c57b5c7a229dee3ccae27a9c2a922..7c12d9c2b23010a54c2752a0abac70b1bcf17735 100644 (file)
@@ -139,17 +139,22 @@ static int __oprofilefs_create_file(struct super_block *sb,
        struct dentry *dentry;
        struct inode *inode;
 
+       mutex_lock(&root->d_inode->i_mutex);
        dentry = d_alloc_name(root, name);
-       if (!dentry)
+       if (!dentry) {
+               mutex_unlock(&root->d_inode->i_mutex);
                return -ENOMEM;
+       }
        inode = oprofilefs_get_inode(sb, S_IFREG | perm);
        if (!inode) {
                dput(dentry);
+               mutex_unlock(&root->d_inode->i_mutex);
                return -ENOMEM;
        }
        inode->i_fop = fops;
+       inode->i_private = priv;
        d_add(dentry, inode);
-       dentry->d_inode->i_private = priv;
+       mutex_unlock(&root->d_inode->i_mutex);
        return 0;
 }
 
@@ -212,17 +217,22 @@ struct dentry *oprofilefs_mkdir(struct super_block *sb,
        struct dentry *dentry;
        struct inode *inode;
 
+       mutex_lock(&root->d_inode->i_mutex);
        dentry = d_alloc_name(root, name);
-       if (!dentry)
+       if (!dentry) {
+               mutex_unlock(&root->d_inode->i_mutex);
                return NULL;
+       }
        inode = oprofilefs_get_inode(sb, S_IFDIR | 0755);
        if (!inode) {
                dput(dentry);
+               mutex_unlock(&root->d_inode->i_mutex);
                return NULL;
        }
        inode->i_op = &simple_dir_inode_operations;
        inode->i_fop = &simple_dir_operations;
        d_add(dentry, inode);
+       mutex_unlock(&root->d_inode->i_mutex);
        return dentry;
 }
 
@@ -266,6 +276,7 @@ static struct file_system_type oprofilefs_type = {
        .mount          = oprofilefs_mount,
        .kill_sb        = kill_litter_super,
 };
+MODULE_ALIAS_FS("oprofilefs");
 
 
 int __init oprofilefs_register(void)