Module Name: src Committed By: thorpej Date: Sun Mar 21 17:58:40 UTC 2021
Modified Files: src/sys/kern [thorpej-cfargs]: subr_autoconf.c Log Message: In config_search(), we already asserted that either an interface attribute is not specified, or the specified attribute is carried by the parent. Add an additional assertion: That an interface attribute is specified or that the parent has fewer than 2 interface attributes (i.e. lack of interface attribute specification would be ambiguous). Yes, "fewer than 2". Zero interface attributes doesn't really make sense, because a device cannot then be a parent of another device by definition. But cfparent_match() would already catch this situation gracefully, and there is obviously no ambiguity when a device has no interface attributes. To generate a diff of this commit: cvs rdiff -u -r1.277.2.1 -r1.277.2.2 src/sys/kern/subr_autoconf.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/kern/subr_autoconf.c diff -u src/sys/kern/subr_autoconf.c:1.277.2.1 src/sys/kern/subr_autoconf.c:1.277.2.2 --- src/sys/kern/subr_autoconf.c:1.277.2.1 Sat Mar 20 19:33:41 2021 +++ src/sys/kern/subr_autoconf.c Sun Mar 21 17:58:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.277.2.1 2021/03/20 19:33:41 thorpej Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.277.2.2 2021/03/21 17:58:40 thorpej 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.277.2.1 2021/03/20 19:33:41 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.277.2.2 2021/03/21 17:58:40 thorpej Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -809,6 +809,23 @@ cfdriver_get_iattr(const struct cfdriver return 0; } +#if defined(DIAGNOSTIC) +static int +cfdriver_iattr_count(const struct cfdriver *cd) +{ + const struct cfiattrdata * const *cpp; + int i; + + if (cd->cd_attrs == NULL) + return 0; + + for (i = 0, cpp = cd->cd_attrs; *cpp; cpp++) { + i++; + } + return i; +} +#endif /* DIAGNOSTIC */ + /* * Lookup an interface attribute description by name. * If the driver is given, consider only its supported attributes. @@ -1071,6 +1088,7 @@ config_vsearch(device_t parent, void *au KASSERT(config_initialized); KASSERT(!ifattr || cfdriver_get_iattr(parent->dv_cfdriver, ifattr)); + KASSERT(ifattr || cfdriver_iattr_count(parent->dv_cfdriver) < 2); m.fn = fn; m.parent = parent;