Skip to content

Commit 7fc7117

Browse files
Al Virobrauner
authored andcommitted
->mnt_devname is never NULL
Not since 8f29188 "new helpers: vfs_create_mount(), fc_mount()" back in 2018. Get rid of the dead checks... Signed-off-by: Al Viro <[email protected]> Link: https://lore.kernel.org/20250421033509.GV2023217@ZenIV Signed-off-by: Christian Brauner <[email protected]>
1 parent a68cb18 commit 7fc7117

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

fs/namespace.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,13 @@ static struct mount *alloc_vfsmnt(const char *name)
355355
if (err)
356356
goto out_free_cache;
357357

358-
if (name) {
358+
if (name)
359359
mnt->mnt_devname = kstrdup_const(name,
360360
GFP_KERNEL_ACCOUNT);
361-
if (!mnt->mnt_devname)
362-
goto out_free_id;
363-
}
361+
else
362+
mnt->mnt_devname = "none";
363+
if (!mnt->mnt_devname)
364+
goto out_free_id;
364365

365366
#ifdef CONFIG_SMP
366367
mnt->mnt_pcp = alloc_percpu(struct mnt_pcp);
@@ -1268,7 +1269,7 @@ struct vfsmount *vfs_create_mount(struct fs_context *fc)
12681269
if (!fc->root)
12691270
return ERR_PTR(-EINVAL);
12701271

1271-
mnt = alloc_vfsmnt(fc->source ?: "none");
1272+
mnt = alloc_vfsmnt(fc->source);
12721273
if (!mnt)
12731274
return ERR_PTR(-ENOMEM);
12741275

@@ -5483,7 +5484,7 @@ static int statmount_sb_source(struct kstatmount *s, struct seq_file *seq)
54835484
seq->buf[seq->count] = '\0';
54845485
seq->count = start;
54855486
seq_commit(seq, string_unescape_inplace(seq->buf + start, UNESCAPE_OCTAL));
5486-
} else if (r->mnt_devname) {
5487+
} else {
54875488
seq_puts(seq, r->mnt_devname);
54885489
}
54895490
return 0;

fs/proc_namespace.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int show_vfsmnt(struct seq_file *m, struct vfsmount *mnt)
111111
if (err)
112112
goto out;
113113
} else {
114-
mangle(m, r->mnt_devname ? r->mnt_devname : "none");
114+
mangle(m, r->mnt_devname);
115115
}
116116
seq_putc(m, ' ');
117117
/* 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)
177177
if (err)
178178
goto out;
179179
} else {
180-
mangle(m, r->mnt_devname ? r->mnt_devname : "none");
180+
mangle(m, r->mnt_devname);
181181
}
182182
seq_puts(m, sb_rdonly(sb) ? " ro" : " rw");
183183
err = show_sb_opts(m, sb);
@@ -199,17 +199,13 @@ static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt)
199199
int err;
200200

201201
/* device */
202+
seq_puts(m, "device ");
202203
if (sb->s_op->show_devname) {
203-
seq_puts(m, "device ");
204204
err = sb->s_op->show_devname(m, mnt_path.dentry);
205205
if (err)
206206
goto out;
207207
} else {
208-
if (r->mnt_devname) {
209-
seq_puts(m, "device ");
210-
mangle(m, r->mnt_devname);
211-
} else
212-
seq_puts(m, "no device");
208+
mangle(m, r->mnt_devname);
213209
}
214210

215211
/* mount point */

0 commit comments

Comments
 (0)