diff options
Diffstat (limited to 'mm/shmem.c')
-rw-r--r-- | mm/shmem.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index 4fb41c83daca..ef8f47473c5a 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -2647,32 +2647,29 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags | |||
2647 | if (!dentry) | 2647 | if (!dentry) |
2648 | goto put_memory; | 2648 | goto put_memory; |
2649 | 2649 | ||
2650 | error = -ENFILE; | ||
2651 | file = get_empty_filp(); | ||
2652 | if (!file) | ||
2653 | goto put_dentry; | ||
2654 | |||
2655 | error = -ENOSPC; | 2650 | error = -ENOSPC; |
2656 | inode = shmem_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0, flags); | 2651 | inode = shmem_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0, flags); |
2657 | if (!inode) | 2652 | if (!inode) |
2658 | goto close_file; | 2653 | goto put_dentry; |
2659 | 2654 | ||
2660 | d_instantiate(dentry, inode); | 2655 | d_instantiate(dentry, inode); |
2661 | inode->i_size = size; | 2656 | inode->i_size = size; |
2662 | inode->i_nlink = 0; /* It is unlinked */ | 2657 | inode->i_nlink = 0; /* It is unlinked */ |
2663 | init_file(file, shm_mnt, dentry, FMODE_WRITE | FMODE_READ, | ||
2664 | &shmem_file_operations); | ||
2665 | |||
2666 | #ifndef CONFIG_MMU | 2658 | #ifndef CONFIG_MMU |
2667 | error = ramfs_nommu_expand_for_mapping(inode, size); | 2659 | error = ramfs_nommu_expand_for_mapping(inode, size); |
2668 | if (error) | 2660 | if (error) |
2669 | goto close_file; | 2661 | goto put_dentry; |
2670 | #endif | 2662 | #endif |
2663 | |||
2664 | error = -ENFILE; | ||
2665 | file = alloc_file(shm_mnt, dentry, FMODE_WRITE | FMODE_READ, | ||
2666 | &shmem_file_operations); | ||
2667 | if (!file) | ||
2668 | goto put_dentry; | ||
2669 | |||
2671 | ima_counts_get(file); | 2670 | ima_counts_get(file); |
2672 | return file; | 2671 | return file; |
2673 | 2672 | ||
2674 | close_file: | ||
2675 | put_filp(file); | ||
2676 | put_dentry: | 2673 | put_dentry: |
2677 | dput(dentry); | 2674 | dput(dentry); |
2678 | put_memory: | 2675 | put_memory: |