Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/tmpfs In the event that loading the root vnode fails, ...



details:   https://anonhg.NetBSD.org/src/rev/79691ff2c15b
branches:  trunk
changeset: 347445:79691ff2c15b
user:      dholland <dholland%NetBSD.org@localhost>
date:      Fri Aug 26 21:44:24 2016 +0000

description:
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)

diffstat:

 sys/fs/tmpfs/tmpfs_vfsops.c |  14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r cc403330cee3 -r 79691ff2c15b sys/fs/tmpfs/tmpfs_vfsops.c
--- a/sys/fs/tmpfs/tmpfs_vfsops.c       Fri Aug 26 20:29:31 2016 +0000
+++ b/sys/fs/tmpfs/tmpfs_vfsops.c       Fri Aug 26 21:44:24 2016 +0000
@@ -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 @@
        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



Home | Main Index | Thread Index | Old Index