diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-06-10 05:04:43 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-14 08:33:33 -0400 |
commit | 3d8a00d2099ebc6d5a6e95fadaf861709d9919a8 (patch) | |
tree | 317bfb9d71e3ef35746685c6da2397545917d81e | |
parent | 47237687d73cbeae1dd7a133c3fc3d7239094568 (diff) |
don't modify od->filp at all
make put_filp() conditional on flag set by finish_open()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/namei.c | 4 | ||||
-rw-r--r-- | fs/open.c | 5 |
2 files changed, 3 insertions, 6 deletions
diff --git a/fs/namei.c b/fs/namei.c index 7a33f074e5bd..18b9326d951f 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -2708,10 +2708,8 @@ out: | |||
2708 | path_put(&nd->root); | 2708 | path_put(&nd->root); |
2709 | if (base) | 2709 | if (base) |
2710 | fput(base); | 2710 | fput(base); |
2711 | if (od.filp) { | 2711 | if (!(opened & FILE_OPENED)) |
2712 | BUG_ON(od.filp->f_path.dentry); | ||
2713 | put_filp(od.filp); | 2712 | put_filp(od.filp); |
2714 | } | ||
2715 | if (res == ERR_PTR(-EOPENSTALE)) { | 2713 | if (res == ERR_PTR(-EOPENSTALE)) { |
2716 | if (flags & LOOKUP_RCU) | 2714 | if (flags & LOOKUP_RCU) |
2717 | res = ERR_PTR(-ECHILD); | 2715 | res = ERR_PTR(-ECHILD); |
@@ -786,15 +786,14 @@ struct file *finish_open(struct opendata *od, struct dentry *dentry, | |||
786 | int *opened) | 786 | int *opened) |
787 | { | 787 | { |
788 | struct file *res; | 788 | struct file *res; |
789 | BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */ | ||
789 | 790 | ||
790 | mntget(od->mnt); | 791 | mntget(od->mnt); |
791 | dget(dentry); | 792 | dget(dentry); |
792 | 793 | ||
793 | res = do_dentry_open(dentry, od->mnt, od->filp, open, current_cred()); | 794 | res = do_dentry_open(dentry, od->mnt, od->filp, open, current_cred()); |
794 | if (!IS_ERR(res)) { | 795 | if (!IS_ERR(res)) |
795 | *opened |= FILE_OPENED; | 796 | *opened |= FILE_OPENED; |
796 | od->filp = NULL; | ||
797 | } | ||
798 | 797 | ||
799 | return res; | 798 | return res; |
800 | } | 799 | } |