[PATCH v4 47/59] namei.c: convert getname_kernel() callers to CLASS(filename_kernel)

Al Viro
2026-01-08T07:36:58Z

fs/namei.c | 36 ++++++++++--------------------------
1 file changed, 10 insertions(+), 26 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 5acb071c92c4..325a69f2bfff 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2993,7 +2993,7 @@ static struct dentry *__start_removing_path(int dfd, struct filename *name,
struct dentry *kern_path_parent(const char *name, struct path *path)
{
struct path parent_path __free(path_put) = {};
- struct filename *filename __free(putname) = getname_kernel(name);
+ CLASS(filename_kernel, filename)(name);
struct dentry *d;
struct qstr last;
int type, error;
@@ -3014,11 +3014,8 @@ struct dentry *kern_path_parent(const char *name, struct path *path)

struct dentry *start_removing_path(const char *name, struct path *path)
{
- struct filename *filename = getname_kernel(name);
- struct dentry *res = __start_removing_path(AT_FDCWD, filename, path);
-
- putname(filename);
- return res;
+ CLASS(filename_kernel, filename)(name);
+ return __start_removing_path(AT_FDCWD, filename, path);
}

struct dentry *start_removing_user_path_at(int dfd,
@@ -3035,12 +3032,8 @@ EXPORT_SYMBOL(start_removing_user_path_at);

int kern_path(const char *name, unsigned int flags, struct path *path)
{
- struct filename *filename = getname_kernel(name);
- int ret = filename_lookup(AT_FDCWD, filename, flags, path, NULL);
-
- putname(filename);
- return ret;
-
+ CLASS(filename_kernel, filename)(name);
+ return filename_lookup(AT_FDCWD, filename, flags, path, NULL);
}
EXPORT_SYMBOL(kern_path);

@@ -3074,15 +3067,11 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
const char *name, unsigned int flags,
struct path *path)
{
- struct filename *filename;
+ CLASS(filename_kernel, filename)(name);
struct path root = {.mnt = mnt, .dentry = dentry};
- int ret;

- filename = getname_kernel(name);
/* the first argument of filename_lookup() is ignored with root */
- ret = filename_lookup(AT_FDCWD, filename, flags, path, &root);
- putname(filename);
- return ret;
+ return filename_lookup(AT_FDCWD, filename, flags, path, &root);
}
EXPORT_SYMBOL(vfs_path_lookup);

@@ -4879,13 +4868,12 @@ struct file *do_file_open_root(const struct path *root,
{
struct nameidata nd;
struct file *file;
- struct filename *filename;
int flags = op->lookup_flags;

if (d_is_symlink(root->dentry) && op->intent & LOOKUP_OPEN)
return ERR_PTR(-ELOOP);

- filename = getname_kernel(name);
+ CLASS(filename_kernel, filename)(name);
if (IS_ERR(filename))
return ERR_CAST(filename);

@@ -4896,7 +4884,6 @@ struct file *do_file_open_root(const struct path *root,
if (unlikely(file == ERR_PTR(-ESTALE)))
file = path_openat(&nd, op, flags | LOOKUP_REVAL);
restore_nameidata();
- putname(filename);
return file;
}

@@ -4952,11 +4939,8 @@ static struct dentry *filename_create(int dfd, struct filename *name,
struct dentry *start_creating_path(int dfd, const char *pathname,
struct path *path, unsigned int lookup_flags)
{
- struct filename *filename = getname_kernel(pathname);
- struct dentry *res = filename_create(dfd, filename, path, lookup_flags);
-
- putname(filename);
- return res;
+ CLASS(filename_kernel, filename)(pathname);
+ return filename_create(dfd, filename, path, lookup_flags);
}
EXPORT_SYMBOL(start_creating_path);

--
2.47.3