Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs/specfs specfs: Assert v_type is VBLK or VCHR in s...



details:   https://anonhg.NetBSD.org/src/rev/d319f43e621f
branches:  trunk
changeset: 364498:d319f43e621f
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Mar 28 12:34:42 2022 +0000

description:
specfs: Assert v_type is VBLK or VCHR in spec_open.

Nothing else makes sense.  Prune dead branches (and replace default
case by panic).

diffstat:

 sys/miscfs/specfs/spec_vnops.c |  18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diffs (47 lines):

diff -r 6c03834cc916 -r d319f43e621f sys/miscfs/specfs/spec_vnops.c
--- a/sys/miscfs/specfs/spec_vnops.c    Mon Mar 28 12:34:34 2022 +0000
+++ b/sys/miscfs/specfs/spec_vnops.c    Mon Mar 28 12:34:42 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spec_vnops.c,v 1.187 2022/03/28 12:34:34 riastradh Exp $       */
+/*     $NetBSD: spec_vnops.c,v 1.188 2022/03/28 12:34:42 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.187 2022/03/28 12:34:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.188 2022/03/28 12:34:42 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -525,7 +525,10 @@
        sd = sn->sn_dev;
        name = NULL;
        gen = 0;
-       
+
+       KASSERTMSG(vp->v_type == VBLK || vp->v_type == VCHR, "type=%d",
+           vp->v_type);
+
        /*
         * Don't allow open if fs is mounted -nodev.
         */
@@ -644,15 +647,8 @@
 
                break;
 
-       case VNON:
-       case VLNK:
-       case VDIR:
-       case VREG:
-       case VBAD:
-       case VFIFO:
-       case VSOCK:
        default:
-               return 0;
+               panic("invalid specfs vnode type: %d", vp->v_type);
        }
 
        mutex_enter(&device_lock);



Home | Main Index | Thread Index | Old Index