Module Name: src
Committed By: hannken
Date: Thu Nov 10 10:54:14 UTC 2022
Modified Files:
src/sys/fs/tmpfs: tmpfs_vfsops.c
Log Message:
Tmpfs_mount() uses tmpfs_unmount() for cleanup if set_statvfs_info() fails.
This will not work as tmpfs_unmount() needs a suspended file system.
Just call set_statvfs_info() before allocating the root vnode and add
and use a common error exit label.
Reported-by: [email protected]
To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/fs/tmpfs/tmpfs_vfsops.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/fs/tmpfs/tmpfs_vfsops.c
diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.77 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.78
--- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.77 Sat Apr 4 20:49:30 2020
+++ src/sys/fs/tmpfs/tmpfs_vfsops.c Thu Nov 10 10:54:14 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_vfsops.c,v 1.77 2020/04/04 20:49:30 ad Exp $ */
+/* $NetBSD: tmpfs_vfsops.c,v 1.78 2022/11/10 10:54:14 hannken Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.77 2020/04/04 20:49:30 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.78 2022/11/10 10:54:14 hannken Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -196,6 +196,11 @@ tmpfs_mount(struct mount *mp, const char
tmpfs_mntmem_init(tmp, memlimit);
mp->mnt_data = tmp;
+ error = set_statvfs_info(path, UIO_USERSPACE, "tmpfs", UIO_SYSSPACE,
+ mp->mnt_op->vfs_name, mp, curlwp);
+ if (error)
+ goto errout;
+
/* Allocate the root node. */
vattr_null(&va);
va.va_type = VDIR;
@@ -203,13 +208,8 @@ tmpfs_mount(struct mount *mp, const char
va.va_uid = args->ta_root_uid;
va.va_gid = args->ta_root_gid;
error = vcache_new(mp, NULL, &va, NOCRED, NULL, &vp);
- if (error) {
- mp->mnt_data = NULL;
- tmpfs_mntmem_destroy(tmp);
- mutex_destroy(&tmp->tm_lock);
- kmem_free(tmp, sizeof(*tmp));
- return error;
- }
+ if (error)
+ goto errout;
KASSERT(vp != NULL);
root = VP_TO_TMPFS_NODE(vp);
KASSERT(root != NULL);
@@ -224,11 +224,14 @@ tmpfs_mount(struct mount *mp, const char
tmp->tm_root = root;
vrele(vp);
- error = set_statvfs_info(path, UIO_USERSPACE, "tmpfs", UIO_SYSSPACE,
- mp->mnt_op->vfs_name, mp, curlwp);
- if (error) {
- (void)tmpfs_unmount(mp, MNT_FORCE);
- }
+ return 0;
+
+errout:
+ mp->mnt_data = NULL;
+ tmpfs_mntmem_destroy(tmp);
+ mutex_destroy(&tmp->tm_lock);
+ kmem_free(tmp, sizeof(*tmp));
+
return error;
}