->mnt_devname is never NULL
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 21 Apr 2025 03:35:09 +0000 (04:35 +0100)
committerChristian Brauner <brauner@kernel.org>
Fri, 23 May 2025 12:20:44 +0000 (14:20 +0200)
Not since 8f2918898eb5 "new helpers: vfs_create_mount(), fc_mount()"
back in 2018.  Get rid of the dead checks...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/20250421033509.GV2023217@ZenIV
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/namespace.c
fs/proc_namespace.c

index ddb0a688633c1e278af7a50b719d3e918dd700af..924298d11df7b209437bcea3fe33aa9d28eea09c 100644 (file)
@@ -355,12 +355,13 @@ static struct mount *alloc_vfsmnt(const char *name)
                if (err)
                        goto out_free_cache;
 
-               if (name) {
+               if (name)
                        mnt->mnt_devname = kstrdup_const(name,
                                                         GFP_KERNEL_ACCOUNT);
-                       if (!mnt->mnt_devname)
-                               goto out_free_id;
-               }
+               else
+                       mnt->mnt_devname = "none";
+               if (!mnt->mnt_devname)
+                       goto out_free_id;
 
 #ifdef CONFIG_SMP
                mnt->mnt_pcp = alloc_percpu(struct mnt_pcp);
@@ -1268,7 +1269,7 @@ struct vfsmount *vfs_create_mount(struct fs_context *fc)
        if (!fc->root)
                return ERR_PTR(-EINVAL);
 
-       mnt = alloc_vfsmnt(fc->source ?: "none");
+       mnt = alloc_vfsmnt(fc->source);
        if (!mnt)
                return ERR_PTR(-ENOMEM);
 
@@ -5483,7 +5484,7 @@ static int statmount_sb_source(struct kstatmount *s, struct seq_file *seq)
                seq->buf[seq->count] = '\0';
                seq->count = start;
                seq_commit(seq, string_unescape_inplace(seq->buf + start, UNESCAPE_OCTAL));
-       } else if (r->mnt_devname) {
+       } else {
                seq_puts(seq, r->mnt_devname);
        }
        return 0;
index e133b507ddf3941525c1a2b70cd82846569dfa20..5c555db68aa2129576aa7c545b7b0294b87e1e5e 100644 (file)
@@ -111,7 +111,7 @@ static int show_vfsmnt(struct seq_file *m, struct vfsmount *mnt)
                if (err)
                        goto out;
        } else {
-               mangle(m, r->mnt_devname ? r->mnt_devname : "none");
+               mangle(m, r->mnt_devname);
        }
        seq_putc(m, ' ');
        /* mountpoints outside of chroot jail will give SEQ_SKIP on this */
@@ -177,7 +177,7 @@ static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt)
                if (err)
                        goto out;
        } else {
-               mangle(m, r->mnt_devname ? r->mnt_devname : "none");
+               mangle(m, r->mnt_devname);
        }
        seq_puts(m, sb_rdonly(sb) ? " ro" : " rw");
        err = show_sb_opts(m, sb);
@@ -199,17 +199,13 @@ static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt)
        int err;
 
        /* device */
+       seq_puts(m, "device ");
        if (sb->s_op->show_devname) {
-               seq_puts(m, "device ");
                err = sb->s_op->show_devname(m, mnt_path.dentry);
                if (err)
                        goto out;
        } else {
-               if (r->mnt_devname) {
-                       seq_puts(m, "device ");
-                       mangle(m, r->mnt_devname);
-               } else
-                       seq_puts(m, "no device");
+               mangle(m, r->mnt_devname);
        }
 
        /* mount point */