Module Name: src
Committed By: dholland
Date: Fri Aug 26 21:44:24 UTC 2016
Modified Files:
src/sys/fs/tmpfs: tmpfs_vfsops.c
Log Message:
In the event that loading the root vnode fails, bail out of
tmpfs_mount instead of crashing.
Came up in PR 51436, where kmem issues caused internal allocations to
wrongly fail. However, that could happen for real sometime (e.g.
probably if you tried to mount a new tmpfs when the system was very
low on memory, or possibly for other reasons entirely) and crashing
isn't the ticket.
(This is not a fix for PR 51436)
To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 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.67 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.68
--- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.67 Sat Mar 12 08:51:13 2016
+++ src/sys/fs/tmpfs/tmpfs_vfsops.c Fri Aug 26 21:44:24 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_vfsops.c,v 1.67 2016/03/12 08:51:13 joerg Exp $ */
+/* $NetBSD: tmpfs_vfsops.c,v 1.68 2016/08/26 21:44:24 dholland 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.67 2016/03/12 08:51:13 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.68 2016/08/26 21:44:24 dholland Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -193,8 +193,16 @@ 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, &vp);
+ if (error) {
+ mp->mnt_data = NULL;
+ tmpfs_mntmem_destroy(tmp);
+ mutex_destroy(&tmp->tm_lock);
+ kmem_free(tmp, sizeof(*tmp));
+ return error;
+ }
+ KASSERT(vp != NULL);
root = VP_TO_TMPFS_NODE(vp);
- KASSERT(error == 0 && root != NULL);
+ KASSERT(root != NULL);
/*
* Parent of the root inode is itself. Also, root inode has no