summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2022-03-12 18:31:39 +0000
committerriastradh <riastradh@NetBSD.org>2022-03-12 18:31:39 +0000
commite377a775995aef32aee6c6d0aee921e07d17f2e4 (patch)
treea8ec5c1915ee3e7e0c80dd25637268a168a70236 /sys/dev
parent43695d47669a1ccf0926215476a7107b9cb32bcb (diff)
emdtv(4): If register read fails, read as all zero.
Avoids undefined behaviour if device is yanked or broken. Reported-by: syzbot+18ce1e017b9f802ed287@syzkaller.appspotmail.com
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/emdtv.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/dev/usb/emdtv.c b/sys/dev/usb/emdtv.c
index bbc75495226..f0455ed8437 100644
--- a/sys/dev/usb/emdtv.c
+++ b/sys/dev/usb/emdtv.c
@@ -1,4 +1,4 @@
-/* $NetBSD: emdtv.c,v 1.15 2020/03/14 02:35:33 christos Exp $ */
+/* $NetBSD: emdtv.c,v 1.16 2022/03/12 18:31:39 riastradh Exp $ */
/*-
* Copyright (c) 2008, 2011 Jared D. McNeill <jmcneill@invisible.ca>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emdtv.c,v 1.15 2020/03/14 02:35:33 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emdtv.c,v 1.16 2022/03/12 18:31:39 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -326,9 +326,11 @@ emdtv_read_multi_1(struct emdtv_softc *sc, uint8_t req, uint16_t index,
status = usbd_do_request(sc->sc_udev, &request, datap);
KERNEL_UNLOCK_ONE(curlwp);
- if (status != USBD_NORMAL_COMPLETION)
+ if (status != USBD_NORMAL_COMPLETION) {
aprint_error_dev(sc->sc_dev, "couldn't read %x/%x: %s\n",
req, index, usbd_errstr(status));
+ memset(datap, 0, count);
+ }
if (emdtv_debug_regs) {
int i;