Module Name: src Committed By: riastradh Date: Fri Jul 1 01:06:31 UTC 2022
Modified Files: src/sys/dev/usb: uvideo.c Log Message: uvideo(4): Assert number of units can't overflow. Not sure if this is true, but at least we'll trap instead of silently undercount this way. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/dev/usb/uvideo.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/usb/uvideo.c diff -u src/sys/dev/usb/uvideo.c:1.81 src/sys/dev/usb/uvideo.c:1.82 --- src/sys/dev/usb/uvideo.c:1.81 Sat May 14 15:29:08 2022 +++ src/sys/dev/usb/uvideo.c Fri Jul 1 01:06:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: uvideo.c,v 1.81 2022/05/14 15:29:08 riastradh Exp $ */ +/* $NetBSD: uvideo.c,v 1.82 2022/07/01 01:06:31 riastradh Exp $ */ /* * Copyright (c) 2008 Patrick Mahoney @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.81 2022/05/14 15:29:08 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.82 2022/07/01 01:06:31 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -811,6 +811,7 @@ uvideo_init_control(struct uvideo_softc if (uvdesc->bDescriptorSubtype < UDESC_INPUT_TERMINAL || uvdesc->bDescriptorSubtype > UDESC_EXTENSION_UNIT) continue; + KASSERT(nunits < 255); ++nunits; } @@ -843,6 +844,7 @@ uvideo_init_control(struct uvideo_softc /* TODO: free other units before returning? */ if (sc->sc_unit[i] == NULL) goto enomem; + KASSERT(i < 255); ++i; }