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)
This commit is contained in:
dholland 2016-08-26 21:44:24 +00:00
parent c63a839724
commit b5981bcf46
1 changed files with 11 additions and 3 deletions

View File

@ -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 *path, void *data, size_t *data_len)
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