aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-07-19 17:15:31 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-29 13:24:13 -0400
commit921a1650de9eed40dd64d681aba4a4d98856f289 (patch)
treec4740f5ee8de85ebbb1b519acf2b8e249bce0c56
parent25b2692a8ace4c2684d3899a0bfe55f8c4248899 (diff)
new helper: done_path_create()
releases what needs to be released after {kern,user}_path_create() Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--arch/powerpc/platforms/cell/spufs/syscalls.c4
-rw-r--r--drivers/base/devtmpfs.c9
-rw-r--r--fs/namei.c24
-rw-r--r--fs/ocfs2/refcounttree.c4
-rw-r--r--include/linux/namei.h1
-rw-r--r--net/unix/af_unix.c9
6 files changed, 21 insertions, 30 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/syscalls.c b/arch/powerpc/platforms/cell/spufs/syscalls.c
index 8591bb62d7fc..5b7d8ffbf890 100644
--- a/arch/powerpc/platforms/cell/spufs/syscalls.c
+++ b/arch/powerpc/platforms/cell/spufs/syscalls.c
@@ -70,9 +70,7 @@ static long do_spu_create(const char __user *pathname, unsigned int flags,
70 ret = PTR_ERR(dentry); 70 ret = PTR_ERR(dentry);
71 if (!IS_ERR(dentry)) { 71 if (!IS_ERR(dentry)) {
72 ret = spufs_create(&path, dentry, flags, mode, neighbor); 72 ret = spufs_create(&path, dentry, flags, mode, neighbor);
73 mutex_unlock(&path.dentry->d_inode->i_mutex); 73 done_path_create(&path, dentry);
74 dput(dentry);
75 path_put(&path);
76 } 74 }
77 75
78 return ret; 76 return ret;
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index d91a3a0b2325..deb4a456cf83 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -156,9 +156,7 @@ static int dev_mkdir(const char *name, umode_t mode)
156 if (!err) 156 if (!err)
157 /* mark as kernel-created inode */ 157 /* mark as kernel-created inode */
158 dentry->d_inode->i_private = &thread; 158 dentry->d_inode->i_private = &thread;
159 dput(dentry); 159 done_path_create(&path, dentry);
160 mutex_unlock(&path.dentry->d_inode->i_mutex);
161 path_put(&path);
162 return err; 160 return err;
163} 161}
164 162
@@ -218,10 +216,7 @@ static int handle_create(const char *nodename, umode_t mode, struct device *dev)
218 /* mark as kernel-created inode */ 216 /* mark as kernel-created inode */
219 dentry->d_inode->i_private = &thread; 217 dentry->d_inode->i_private = &thread;
220 } 218 }
221 dput(dentry); 219 done_path_create(&path, dentry);
222
223 mutex_unlock(&path.dentry->d_inode->i_mutex);
224 path_put(&path);
225 return err; 220 return err;
226} 221}
227 222
diff --git a/fs/namei.c b/fs/namei.c
index 2ccc35c4dc24..5bc6f3d1dc8a 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2893,6 +2893,14 @@ out:
2893} 2893}
2894EXPORT_SYMBOL(kern_path_create); 2894EXPORT_SYMBOL(kern_path_create);
2895 2895
2896void done_path_create(struct path *path, struct dentry *dentry)
2897{
2898 dput(dentry);
2899 mutex_unlock(&path->dentry->d_inode->i_mutex);
2900 path_put(path);
2901}
2902EXPORT_SYMBOL(done_path_create);
2903
2896struct dentry *user_path_create(int dfd, const char __user *pathname, struct path *path, int is_dir) 2904struct dentry *user_path_create(int dfd, const char __user *pathname, struct path *path, int is_dir)
2897{ 2905{
2898 char *tmp = getname(pathname); 2906 char *tmp = getname(pathname);
@@ -2989,9 +2997,7 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode,
2989out_drop_write: 2997out_drop_write:
2990 mnt_drop_write(path.mnt); 2998 mnt_drop_write(path.mnt);
2991out_dput: 2999out_dput:
2992 dput(dentry); 3000 done_path_create(&path, dentry);
2993 mutex_unlock(&path.dentry->d_inode->i_mutex);
2994 path_put(&path);
2995 3001
2996 return error; 3002 return error;
2997} 3003}
@@ -3048,9 +3054,7 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
3048out_drop_write: 3054out_drop_write:
3049 mnt_drop_write(path.mnt); 3055 mnt_drop_write(path.mnt);
3050out_dput: 3056out_dput:
3051 dput(dentry); 3057 done_path_create(&path, dentry);
3052 mutex_unlock(&path.dentry->d_inode->i_mutex);
3053 path_put(&path);
3054 return error; 3058 return error;
3055} 3059}
3056 3060
@@ -3334,9 +3338,7 @@ SYSCALL_DEFINE3(symlinkat, const char __user *, oldname,
3334out_drop_write: 3338out_drop_write:
3335 mnt_drop_write(path.mnt); 3339 mnt_drop_write(path.mnt);
3336out_dput: 3340out_dput:
3337 dput(dentry); 3341 done_path_create(&path, dentry);
3338 mutex_unlock(&path.dentry->d_inode->i_mutex);
3339 path_put(&path);
3340out_putname: 3342out_putname:
3341 putname(from); 3343 putname(from);
3342 return error; 3344 return error;
@@ -3446,9 +3448,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
3446out_drop_write: 3448out_drop_write:
3447 mnt_drop_write(new_path.mnt); 3449 mnt_drop_write(new_path.mnt);
3448out_dput: 3450out_dput:
3449 dput(new_dentry); 3451 done_path_create(&new_path, new_dentry);
3450 mutex_unlock(&new_path.dentry->d_inode->i_mutex);
3451 path_put(&new_path);
3452out: 3452out:
3453 path_put(&old_path); 3453 path_put(&old_path);
3454 3454
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 9f32d7cbb7a3..23cf78f68503 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -4477,9 +4477,7 @@ int ocfs2_reflink_ioctl(struct inode *inode,
4477 new_dentry, preserve); 4477 new_dentry, preserve);
4478 mnt_drop_write(new_path.mnt); 4478 mnt_drop_write(new_path.mnt);
4479out_dput: 4479out_dput:
4480 dput(new_dentry); 4480 done_path_create(&new_path, new_dentry);
4481 mutex_unlock(&new_path.dentry->d_inode->i_mutex);
4482 path_put(&new_path);
4483out: 4481out:
4484 path_put(&old_path); 4482 path_put(&old_path);
4485 4483
diff --git a/include/linux/namei.h b/include/linux/namei.h
index d2ef8b34b967..4bf19d8174ed 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -67,6 +67,7 @@ extern int kern_path(const char *, unsigned, struct path *);
67 67
68extern struct dentry *kern_path_create(int, const char *, struct path *, int); 68extern struct dentry *kern_path_create(int, const char *, struct path *, int);
69extern struct dentry *user_path_create(int, const char __user *, struct path *, int); 69extern struct dentry *user_path_create(int, const char __user *, struct path *, int);
70extern void done_path_create(struct path *, struct dentry *);
70extern struct dentry *kern_path_locked(const char *, struct path *); 71extern struct dentry *kern_path_locked(const char *, struct path *);
71extern int vfs_path_lookup(struct dentry *, struct vfsmount *, 72extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
72 const char *, unsigned int, struct path *); 73 const char *, unsigned int, struct path *);
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 641f2e47f165..e8239540683a 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -887,8 +887,9 @@ out_mknod_drop_write:
887 mnt_drop_write(path.mnt); 887 mnt_drop_write(path.mnt);
888 if (err) 888 if (err)
889 goto out_mknod_dput; 889 goto out_mknod_dput;
890 mutex_unlock(&path.dentry->d_inode->i_mutex); 890 mntget(path.mnt);
891 dput(path.dentry); 891 dget(dentry);
892 done_path_create(&path, dentry);
892 path.dentry = dentry; 893 path.dentry = dentry;
893 894
894 addr->hash = UNIX_HASH_SIZE; 895 addr->hash = UNIX_HASH_SIZE;
@@ -923,9 +924,7 @@ out:
923 return err; 924 return err;
924 925
925out_mknod_dput: 926out_mknod_dput:
926 dput(dentry); 927 done_path_create(&path, dentry);
927 mutex_unlock(&path.dentry->d_inode->i_mutex);
928 path_put(&path);
929out_mknod_parent: 928out_mknod_parent:
930 if (err == -EEXIST) 929 if (err == -EEXIST)
931 err = -EADDRINUSE; 930 err = -EADDRINUSE;