diff options
| author | riastradh <riastradh@NetBSD.org> | 2022-07-01 01:06:31 +0000 |
|---|---|---|
| committer | riastradh <riastradh@NetBSD.org> | 2022-07-01 01:06:31 +0000 |
| commit | 2abb1c26a795a44c77db9148900d9d1d0fa348d9 (patch) | |
| tree | b82ae569f99367e60a5bf045b0b0d3dc1b39e068 /sys/dev | |
| parent | 22e17a50988af8a34e6318811838495cb3f37a5a (diff) | |
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.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/usb/uvideo.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c index 692bf03b36a..fe0c8ffb293 100644 --- a/sys/dev/usb/uvideo.c +++ b/sys/dev/usb/uvideo.c @@ -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 *sc, 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 *sc, /* TODO: free other units before returning? */ if (sc->sc_unit[i] == NULL) goto enomem; + KASSERT(i < 255); ++i; } |
