Module Name: src Committed By: riastradh Date: Mon Oct 3 19:13:09 UTC 2022
Modified Files: src/sys/dev: cons.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/dev/cons.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/dev/cons.c diff -u src/sys/dev/cons.c:1.81 src/sys/dev/cons.c:1.82 --- src/sys/dev/cons.c:1.81 Mon Oct 3 19:12:51 2022 +++ src/sys/dev/cons.c Mon Oct 3 19:13:08 2022 @@ -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 @@ cnclose(dev_t dev, int flag, int mode, s int unit, error; unit = minor(dev); + if (unit > 1) + return ENODEV; mutex_enter(&cn_lock);