Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb emdtv(4): If register read fails, read as all zero.



details:   https://anonhg.NetBSD.org/src/rev/cb5b9c755080
branches:  trunk
changeset: 363448:cb5b9c755080
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Mar 12 18:31:39 2022 +0000

description:
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@localhost

diffstat:

 sys/dev/usb/emdtv.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (31 lines):

diff -r 5fd7678b395a -r cb5b9c755080 sys/dev/usb/emdtv.c
--- a/sys/dev/usb/emdtv.c       Sat Mar 12 17:45:53 2022 +0000
+++ b/sys/dev/usb/emdtv.c       Sat Mar 12 18:31:39 2022 +0000
@@ -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@localhost>
@@ -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 @@
        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;



Home | Main Index | Thread Index | Old Index