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 /fs/pipe.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 'fs/pipe.c')
-rw-r--r-- | fs/pipe.c | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -974,7 +974,7 @@ struct file *create_write_pipe(int flags) | |||
974 | int err; | 974 | int err; |
975 | struct inode *inode; | 975 | struct inode *inode; |
976 | struct file *f; | 976 | struct file *f; |
977 | struct dentry *dentry; | 977 | struct path path; |
978 | struct qstr name = { .name = "" }; | 978 | struct qstr name = { .name = "" }; |
979 | 979 | ||
980 | err = -ENFILE; | 980 | err = -ENFILE; |
@@ -983,21 +983,22 @@ struct file *create_write_pipe(int flags) | |||
983 | goto err; | 983 | goto err; |
984 | 984 | ||
985 | err = -ENOMEM; | 985 | err = -ENOMEM; |
986 | dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &name); | 986 | path.dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &name); |
987 | if (!dentry) | 987 | if (!path.dentry) |
988 | goto err_inode; | 988 | goto err_inode; |
989 | path.mnt = mntget(pipe_mnt); | ||
989 | 990 | ||
990 | dentry->d_op = &pipefs_dentry_operations; | 991 | path.dentry->d_op = &pipefs_dentry_operations; |
991 | /* | 992 | /* |
992 | * We dont want to publish this dentry into global dentry hash table. | 993 | * We dont want to publish this dentry into global dentry hash table. |
993 | * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED | 994 | * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED |
994 | * This permits a working /proc/$pid/fd/XXX on pipes | 995 | * This permits a working /proc/$pid/fd/XXX on pipes |
995 | */ | 996 | */ |
996 | dentry->d_flags &= ~DCACHE_UNHASHED; | 997 | path.dentry->d_flags &= ~DCACHE_UNHASHED; |
997 | d_instantiate(dentry, inode); | 998 | d_instantiate(path.dentry, inode); |
998 | 999 | ||
999 | err = -ENFILE; | 1000 | err = -ENFILE; |
1000 | f = alloc_file(pipe_mnt, dentry, FMODE_WRITE, &write_pipefifo_fops); | 1001 | f = alloc_file(&path, FMODE_WRITE, &write_pipefifo_fops); |
1001 | if (!f) | 1002 | if (!f) |
1002 | goto err_dentry; | 1003 | goto err_dentry; |
1003 | f->f_mapping = inode->i_mapping; | 1004 | f->f_mapping = inode->i_mapping; |
@@ -1009,7 +1010,7 @@ struct file *create_write_pipe(int flags) | |||
1009 | 1010 | ||
1010 | err_dentry: | 1011 | err_dentry: |
1011 | free_pipe_info(inode); | 1012 | free_pipe_info(inode); |
1012 | dput(dentry); | 1013 | path_put(&path); |
1013 | return ERR_PTR(err); | 1014 | return ERR_PTR(err); |
1014 | 1015 | ||
1015 | err_inode: | 1016 | err_inode: |