Skip to content

Commit 1b25dea

Browse files
author
Al Viro
committed
configfs:get_target() - release path as soon as we grab configfs_item reference
... and get rid of path argument - it turns into a local variable in get_target() Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Christian Brauner <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 39e6bc5 commit 1b25dea

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

fs/configfs/symlink.c

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -114,34 +114,28 @@ static int create_link(struct config_item *parent_item,
114114
}
115115

116116

117-
static int get_target(const char *symname, struct path *path,
118-
struct config_item **target, struct super_block *sb)
117+
static int get_target(const char *symname, struct config_item **target,
118+
struct super_block *sb)
119119
{
120+
struct path path __free(path_put) = {};
120121
int ret;
121122

122-
ret = kern_path(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, path);
123-
if (!ret) {
124-
if (path->dentry->d_sb == sb) {
125-
*target = configfs_get_config_item(path->dentry);
126-
if (!*target) {
127-
ret = -ENOENT;
128-
path_put(path);
129-
}
130-
} else {
131-
ret = -EPERM;
132-
path_put(path);
133-
}
134-
}
135-
136-
return ret;
123+
ret = kern_path(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &path);
124+
if (ret)
125+
return ret;
126+
if (path.dentry->d_sb != sb)
127+
return -EPERM;
128+
*target = configfs_get_config_item(path.dentry);
129+
if (!*target)
130+
return -ENOENT;
131+
return 0;
137132
}
138133

139134

140135
int configfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
141136
struct dentry *dentry, const char *symname)
142137
{
143138
int ret;
144-
struct path path;
145139
struct configfs_dirent *sd;
146140
struct config_item *parent_item;
147141
struct config_item *target_item = NULL;
@@ -188,7 +182,7 @@ int configfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
188182
* AV, a thoroughly annoyed bastard.
189183
*/
190184
inode_unlock(dir);
191-
ret = get_target(symname, &path, &target_item, dentry->d_sb);
185+
ret = get_target(symname, &target_item, dentry->d_sb);
192186
inode_lock(dir);
193187
if (ret)
194188
goto out_put;
@@ -210,7 +204,6 @@ int configfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
210204
}
211205

212206
config_item_put(target_item);
213-
path_put(&path);
214207

215208
out_put:
216209
config_item_put(parent_item);

0 commit comments

Comments
 (0)