diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2009-08-08 16:52:35 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-12-16 12:16:42 -0500 |
commit | 2c48b9c45579a9b5e3e74694eebf3d2451f3dbd3 (patch) | |
tree | cecbf786ae0650368a8136bdd90910e05d9b95c3 /mm/shmem.c | |
parent | a95161aaa801c18c52b2e7cf3d6b4b141c00a20a (diff) |
switch alloc_file() to passing struct path
... and have the caller grab both mnt and dentry; kill
leak in infiniband, while we are at it.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm/shmem.c')
-rw-r--r-- | mm/shmem.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index ef8f47473c5a..d2ec7f029ff4 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -2626,7 +2626,8 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags | |||
2626 | int error; | 2626 | int error; |
2627 | struct file *file; | 2627 | struct file *file; |
2628 | struct inode *inode; | 2628 | struct inode *inode; |
2629 | struct dentry *dentry, *root; | 2629 | struct path path; |
2630 | struct dentry *root; | ||
2630 | struct qstr this; | 2631 | struct qstr this; |
2631 | 2632 | ||
2632 | if (IS_ERR(shm_mnt)) | 2633 | if (IS_ERR(shm_mnt)) |
@@ -2643,16 +2644,17 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags | |||
2643 | this.len = strlen(name); | 2644 | this.len = strlen(name); |
2644 | this.hash = 0; /* will go */ | 2645 | this.hash = 0; /* will go */ |
2645 | root = shm_mnt->mnt_root; | 2646 | root = shm_mnt->mnt_root; |
2646 | dentry = d_alloc(root, &this); | 2647 | path.dentry = d_alloc(root, &this); |
2647 | if (!dentry) | 2648 | if (!path.dentry) |
2648 | goto put_memory; | 2649 | goto put_memory; |
2650 | path.mnt = mntget(shm_mnt); | ||
2649 | 2651 | ||
2650 | error = -ENOSPC; | 2652 | error = -ENOSPC; |
2651 | inode = shmem_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0, flags); | 2653 | inode = shmem_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0, flags); |
2652 | if (!inode) | 2654 | if (!inode) |
2653 | goto put_dentry; | 2655 | goto put_dentry; |
2654 | 2656 | ||
2655 | d_instantiate(dentry, inode); | 2657 | d_instantiate(path.dentry, inode); |
2656 | inode->i_size = size; | 2658 | inode->i_size = size; |
2657 | inode->i_nlink = 0; /* It is unlinked */ | 2659 | inode->i_nlink = 0; /* It is unlinked */ |
2658 | #ifndef CONFIG_MMU | 2660 | #ifndef CONFIG_MMU |
@@ -2662,7 +2664,7 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags | |||
2662 | #endif | 2664 | #endif |
2663 | 2665 | ||
2664 | error = -ENFILE; | 2666 | error = -ENFILE; |
2665 | file = alloc_file(shm_mnt, dentry, FMODE_WRITE | FMODE_READ, | 2667 | file = alloc_file(&path, FMODE_WRITE | FMODE_READ, |
2666 | &shmem_file_operations); | 2668 | &shmem_file_operations); |
2667 | if (!file) | 2669 | if (!file) |
2668 | goto put_dentry; | 2670 | goto put_dentry; |
@@ -2671,7 +2673,7 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags | |||
2671 | return file; | 2673 | return file; |
2672 | 2674 | ||
2673 | put_dentry: | 2675 | put_dentry: |
2674 | dput(dentry); | 2676 | path_put(&path); |
2675 | put_memory: | 2677 | put_memory: |
2676 | shmem_unacct_size(flags, size); | 2678 | shmem_unacct_size(flags, size); |
2677 | return ERR_PTR(error); | 2679 | return ERR_PTR(error); |