ide/ppc/pmac.c: add MODULE_LICENSE
[sfrench/cifs-2.6.git] / fs / anon_inodes.c
index 23321889d9b09d89075272ee419d4e00b496f1d8..f42be069e085b2d212b8cc633d61f418be6801f5 100644 (file)
@@ -81,13 +81,10 @@ int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile,
 
        if (IS_ERR(anon_inode_inode))
                return -ENODEV;
-       file = get_empty_filp();
-       if (!file)
-               return -ENFILE;
 
        error = get_unused_fd();
        if (error < 0)
-               goto err_put_filp;
+               return error;
        fd = error;
 
        /*
@@ -114,14 +111,15 @@ int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile,
        dentry->d_flags &= ~DCACHE_UNHASHED;
        d_instantiate(dentry, anon_inode_inode);
 
-       file->f_path.mnt = mntget(anon_inode_mnt);
-       file->f_path.dentry = dentry;
+       error = -ENFILE;
+       file = alloc_file(anon_inode_mnt, dentry,
+                         FMODE_READ | FMODE_WRITE, fops);
+       if (!file)
+               goto err_dput;
        file->f_mapping = anon_inode_inode->i_mapping;
 
        file->f_pos = 0;
        file->f_flags = O_RDWR;
-       file->f_op = fops;
-       file->f_mode = FMODE_READ | FMODE_WRITE;
        file->f_version = 0;
        file->private_data = priv;
 
@@ -132,10 +130,10 @@ int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile,
        *pfile = file;
        return 0;
 
+err_dput:
+       dput(dentry);
 err_put_unused_fd:
        put_unused_fd(fd);
-err_put_filp:
-       put_filp(file);
        return error;
 }
 EXPORT_SYMBOL_GPL(anon_inode_getfd);