]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
do_filp_open(): DTRT when getting ERR_PTR() as pathname
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 25 Sep 2025 21:02:28 +0000 (17:02 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 13 Jan 2026 20:18:07 +0000 (15:18 -0500)
The rest of the set_nameidata() callers treat IS_ERR(pathname) as
"bail out immediately with PTR_ERR(pathname) as error".  Makes
life simpler for callers; do_filp_open() is the only exception
and its callers would also benefit from such calling conventions
change.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namei.c

index f4359825ba4832f27a1b86657c46fc9f628d9983..659c92a6d52cf981b5f29229dcd317853abf13b5 100644 (file)
@@ -4871,6 +4871,8 @@ struct file *do_filp_open(int dfd, struct filename *pathname,
        int flags = op->lookup_flags;
        struct file *filp;
 
+       if (IS_ERR(pathname))
+               return ERR_CAST(pathname);
        set_nameidata(&nd, dfd, pathname, NULL);
        filp = path_openat(&nd, op, flags | LOOKUP_RCU);
        if (unlikely(filp == ERR_PTR(-ECHILD)))