mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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>
This commit is contained in:
parent
25b2692a8a
commit
921a1650de
6 changed files with 21 additions and 30 deletions
|
@ -70,9 +70,7 @@ static long do_spu_create(const char __user *pathname, unsigned int flags,
|
||||||
ret = PTR_ERR(dentry);
|
ret = PTR_ERR(dentry);
|
||||||
if (!IS_ERR(dentry)) {
|
if (!IS_ERR(dentry)) {
|
||||||
ret = spufs_create(&path, dentry, flags, mode, neighbor);
|
ret = spufs_create(&path, dentry, flags, mode, neighbor);
|
||||||
mutex_unlock(&path.dentry->d_inode->i_mutex);
|
done_path_create(&path, dentry);
|
||||||
dput(dentry);
|
|
||||||
path_put(&path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -156,9 +156,7 @@ static int dev_mkdir(const char *name, umode_t mode)
|
||||||
if (!err)
|
if (!err)
|
||||||
/* mark as kernel-created inode */
|
/* mark as kernel-created inode */
|
||||||
dentry->d_inode->i_private = &thread;
|
dentry->d_inode->i_private = &thread;
|
||||||
dput(dentry);
|
done_path_create(&path, dentry);
|
||||||
mutex_unlock(&path.dentry->d_inode->i_mutex);
|
|
||||||
path_put(&path);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,10 +216,7 @@ static int handle_create(const char *nodename, umode_t mode, struct device *dev)
|
||||||
/* mark as kernel-created inode */
|
/* mark as kernel-created inode */
|
||||||
dentry->d_inode->i_private = &thread;
|
dentry->d_inode->i_private = &thread;
|
||||||
}
|
}
|
||||||
dput(dentry);
|
done_path_create(&path, dentry);
|
||||||
|
|
||||||
mutex_unlock(&path.dentry->d_inode->i_mutex);
|
|
||||||
path_put(&path);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
24
fs/namei.c
24
fs/namei.c
|
@ -2893,6 +2893,14 @@ out:
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(kern_path_create);
|
EXPORT_SYMBOL(kern_path_create);
|
||||||
|
|
||||||
|
void done_path_create(struct path *path, struct dentry *dentry)
|
||||||
|
{
|
||||||
|
dput(dentry);
|
||||||
|
mutex_unlock(&path->dentry->d_inode->i_mutex);
|
||||||
|
path_put(path);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(done_path_create);
|
||||||
|
|
||||||
struct dentry *user_path_create(int dfd, const char __user *pathname, struct path *path, int is_dir)
|
struct dentry *user_path_create(int dfd, const char __user *pathname, struct path *path, int is_dir)
|
||||||
{
|
{
|
||||||
char *tmp = getname(pathname);
|
char *tmp = getname(pathname);
|
||||||
|
@ -2989,9 +2997,7 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode,
|
||||||
out_drop_write:
|
out_drop_write:
|
||||||
mnt_drop_write(path.mnt);
|
mnt_drop_write(path.mnt);
|
||||||
out_dput:
|
out_dput:
|
||||||
dput(dentry);
|
done_path_create(&path, dentry);
|
||||||
mutex_unlock(&path.dentry->d_inode->i_mutex);
|
|
||||||
path_put(&path);
|
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -3048,9 +3054,7 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
|
||||||
out_drop_write:
|
out_drop_write:
|
||||||
mnt_drop_write(path.mnt);
|
mnt_drop_write(path.mnt);
|
||||||
out_dput:
|
out_dput:
|
||||||
dput(dentry);
|
done_path_create(&path, dentry);
|
||||||
mutex_unlock(&path.dentry->d_inode->i_mutex);
|
|
||||||
path_put(&path);
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3334,9 +3338,7 @@ SYSCALL_DEFINE3(symlinkat, const char __user *, oldname,
|
||||||
out_drop_write:
|
out_drop_write:
|
||||||
mnt_drop_write(path.mnt);
|
mnt_drop_write(path.mnt);
|
||||||
out_dput:
|
out_dput:
|
||||||
dput(dentry);
|
done_path_create(&path, dentry);
|
||||||
mutex_unlock(&path.dentry->d_inode->i_mutex);
|
|
||||||
path_put(&path);
|
|
||||||
out_putname:
|
out_putname:
|
||||||
putname(from);
|
putname(from);
|
||||||
return error;
|
return error;
|
||||||
|
@ -3446,9 +3448,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
|
||||||
out_drop_write:
|
out_drop_write:
|
||||||
mnt_drop_write(new_path.mnt);
|
mnt_drop_write(new_path.mnt);
|
||||||
out_dput:
|
out_dput:
|
||||||
dput(new_dentry);
|
done_path_create(&new_path, new_dentry);
|
||||||
mutex_unlock(&new_path.dentry->d_inode->i_mutex);
|
|
||||||
path_put(&new_path);
|
|
||||||
out:
|
out:
|
||||||
path_put(&old_path);
|
path_put(&old_path);
|
||||||
|
|
||||||
|
|
|
@ -4477,9 +4477,7 @@ int ocfs2_reflink_ioctl(struct inode *inode,
|
||||||
new_dentry, preserve);
|
new_dentry, preserve);
|
||||||
mnt_drop_write(new_path.mnt);
|
mnt_drop_write(new_path.mnt);
|
||||||
out_dput:
|
out_dput:
|
||||||
dput(new_dentry);
|
done_path_create(&new_path, new_dentry);
|
||||||
mutex_unlock(&new_path.dentry->d_inode->i_mutex);
|
|
||||||
path_put(&new_path);
|
|
||||||
out:
|
out:
|
||||||
path_put(&old_path);
|
path_put(&old_path);
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ extern int kern_path(const char *, unsigned, struct path *);
|
||||||
|
|
||||||
extern struct dentry *kern_path_create(int, const char *, struct path *, int);
|
extern struct dentry *kern_path_create(int, const char *, struct path *, int);
|
||||||
extern struct dentry *user_path_create(int, const char __user *, struct path *, int);
|
extern struct dentry *user_path_create(int, const char __user *, struct path *, int);
|
||||||
|
extern void done_path_create(struct path *, struct dentry *);
|
||||||
extern struct dentry *kern_path_locked(const char *, struct path *);
|
extern struct dentry *kern_path_locked(const char *, struct path *);
|
||||||
extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
|
extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
|
||||||
const char *, unsigned int, struct path *);
|
const char *, unsigned int, struct path *);
|
||||||
|
|
|
@ -887,8 +887,9 @@ out_mknod_drop_write:
|
||||||
mnt_drop_write(path.mnt);
|
mnt_drop_write(path.mnt);
|
||||||
if (err)
|
if (err)
|
||||||
goto out_mknod_dput;
|
goto out_mknod_dput;
|
||||||
mutex_unlock(&path.dentry->d_inode->i_mutex);
|
mntget(path.mnt);
|
||||||
dput(path.dentry);
|
dget(dentry);
|
||||||
|
done_path_create(&path, dentry);
|
||||||
path.dentry = dentry;
|
path.dentry = dentry;
|
||||||
|
|
||||||
addr->hash = UNIX_HASH_SIZE;
|
addr->hash = UNIX_HASH_SIZE;
|
||||||
|
@ -923,9 +924,7 @@ out:
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
out_mknod_dput:
|
out_mknod_dput:
|
||||||
dput(dentry);
|
done_path_create(&path, dentry);
|
||||||
mutex_unlock(&path.dentry->d_inode->i_mutex);
|
|
||||||
path_put(&path);
|
|
||||||
out_mknod_parent:
|
out_mknod_parent:
|
||||||
if (err == -EEXIST)
|
if (err == -EEXIST)
|
||||||
err = -EADDRINUSE;
|
err = -EADDRINUSE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue