Source-Changes-HG archive

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

[src/trunk]: src/sys/dev cons(9): Check the unit number on close too.



details:   https://anonhg.NetBSD.org/src/rev/33460f9c80f4
branches:  trunk
changeset: 371717:33460f9c80f4
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Oct 03 19:13:08 2022 +0000

description:
cons(9): Check the unit number on close too.

Races between multiple opens, some of which fail, might lead to
closing a bad unit number -- not clear there's a good way to prevent
this.

diffstat:

 sys/dev/cons.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r 4bf8ea814856 -r 33460f9c80f4 sys/dev/cons.c
--- a/sys/dev/cons.c    Mon Oct 03 19:12:51 2022 +0000
+++ b/sys/dev/cons.c    Mon Oct 03 19:13:08 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cons.c,v 1.81 2022/10/03 19:12:51 riastradh Exp $      */
+/*     $NetBSD: cons.c,v 1.82 2022/10/03 19:13:08 riastradh Exp $      */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.81 2022/10/03 19:12:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.82 2022/10/03 19:13:08 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -175,6 +175,8 @@
        int unit, error;
 
        unit = minor(dev);
+       if (unit > 1)
+               return ENODEV;
 
        mutex_enter(&cn_lock);
 



Home | Main Index | Thread Index | Old Index