Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern autoconf(9): Refuse to consider negative unit numbe...
details: https://anonhg.NetBSD.org/src/rev/14273617912c
branches: trunk
changeset: 363449:14273617912c
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Mar 12 19:26:33 2022 +0000
description:
autoconf(9): Refuse to consider negative unit numbers in cfdata.
Reported-by: syzbot+a63ae6c58df86f40b6f3%syzkaller.appspotmail.com@localhost
diffstat:
sys/kern/subr_autoconf.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diffs (42 lines):
diff -r cb5b9c755080 -r 14273617912c sys/kern/subr_autoconf.c
--- a/sys/kern/subr_autoconf.c Sat Mar 12 18:31:39 2022 +0000
+++ b/sys/kern/subr_autoconf.c Sat Mar 12 19:26:33 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.295 2022/02/06 19:29:52 tnn Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.296 2022/03/12 19:26:33 riastradh Exp $ */
/*
* Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.295 2022/02/06 19:29:52 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.296 2022/03/12 19:26:33 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -1473,10 +1473,12 @@
static int
config_unit_nextfree(cfdriver_t cd, cfdata_t cf)
{
- int unit;
-
+ int unit = cf->cf_unit;
+
+ if (unit < 0)
+ return -1;
if (cf->cf_fstate == FSTATE_STAR) {
- for (unit = cf->cf_unit; unit < cd->cd_ndevs; unit++)
+ for (; unit < cd->cd_ndevs; unit++)
if (cd->cd_devs[unit] == NULL)
break;
/*
@@ -1484,7 +1486,6 @@
* or max(cd->cd_ndevs,cf->cf_unit).
*/
} else {
- unit = cf->cf_unit;
if (unit < cd->cd_ndevs && cd->cd_devs[unit] != NULL)
unit = -1;
}
Home |
Main Index |
Thread Index |
Old Index