diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2026-05-09 12:41:46 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2026-06-08 14:53:09 -0400 |
| commit | 5cefe23f63742881229ea80a55b5f9e5021966bc (patch) | |
| tree | 7da43e68366c8d40c6b6e4cadec7810fe9dde49d | |
| parent | 9b9e8bb81c41fd27e7b57a1c936fde140548535f (diff) | |
| download | linux-stable-5cefe23f63742881229ea80a55b5f9e5021966bc.tar.gz linux-stable-5cefe23f63742881229ea80a55b5f9e5021966bc.zip | |
configfs_mkdir(): use take_dentry_name_snapshot()
Note that neither ->make_group() nor ->make_item() are allowed to modify
the string passed to them - the argument is const char *.
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| -rw-r--r-- | fs/configfs/dir.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index eb991b2a9c34..8181771c8a58 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -1329,7 +1329,11 @@ static struct dentry *configfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, const struct config_item_type *type; struct module *subsys_owner = NULL, *new_item_owner = NULL; struct configfs_fragment *frag; - char *name; + struct name_snapshot n; + const char *name; + + take_dentry_name_snapshot(&n, dentry); + name = n.name.name; sd = dentry->d_parent->d_fsdata; @@ -1381,14 +1385,6 @@ static struct dentry *configfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, goto out_put; } - name = kmalloc(dentry->d_name.len + 1, GFP_KERNEL); - if (!name) { - ret = -ENOMEM; - goto out_subsys_put; - } - - snprintf(name, dentry->d_name.len + 1, "%s", dentry->d_name.name); - mutex_lock(&subsys->su_mutex); if (type->ct_group_ops->make_group) { group = type->ct_group_ops->make_group(to_config_group(parent_item), name); @@ -1410,7 +1406,6 @@ static struct dentry *configfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, } mutex_unlock(&subsys->su_mutex); - kfree(name); if (ret) { /* * If ret != 0, then link_obj() was never called. @@ -1497,6 +1492,7 @@ out_put: put_fragment(frag); out: + release_dentry_name_snapshot(&n); return ERR_PTR(ret); } |
