[PATCH v4 18/59] switch __getname_maybe_null() to CLASS(filename_flags)

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

fs/namei.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 15e14802cabb..f8c11e1a6b11 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -227,7 +227,6 @@ struct filename *getname_uflags(const char __user *filename, int uflags)

struct filename *__getname_maybe_null(const char __user *pathname)
{
- struct filename *name;
char c;

/* try to save on allocations; loss on um, though */
@@ -236,12 +235,11 @@ struct filename *__getname_maybe_null(const char __user *pathname)
if (!c)
return NULL;

- name = getname_flags(pathname, LOOKUP_EMPTY);
- if (!IS_ERR(name) && !(name->name[0])) {
- putname(name);
- name = NULL;
- }
- return name;
+ CLASS(filename_flags, name)(pathname, LOOKUP_EMPTY);
+ /* empty pathname translates to NULL */
+ if (!IS_ERR(name) && !(name->name[0]))
+ return NULL;
+ return no_free_ptr(name);
}

struct filename *getname_kernel(const char * filename)
--
2.47.3