Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb ucom(4): Make sure rndsource is attached before ...



details:   https://anonhg.NetBSD.org/src/rev/c00757c1bad7
branches:  trunk
changeset: 365276:c00757c1bad7
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Apr 17 09:25:24 2022 +0000

description:
ucom(4): Make sure rndsource is attached before use and detach.

Reported-by: syzbot+04fb6786e0cf873905e8%syzkaller.appspotmail.com@localhost

diffstat:

 sys/dev/usb/ucom.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (38 lines):

diff -r 9bc4d72211cb -r c00757c1bad7 sys/dev/usb/ucom.c
--- a/sys/dev/usb/ucom.c        Sun Apr 17 09:09:13 2022 +0000
+++ b/sys/dev/usb/ucom.c        Sun Apr 17 09:25:24 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ucom.c,v 1.132 2022/04/07 21:47:02 riastradh Exp $     */
+/*     $NetBSD: ucom.c,v 1.133 2022/04/17 09:25:24 riastradh Exp $     */
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.132 2022/04/07 21:47:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.133 2022/04/17 09:25:24 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -299,6 +299,9 @@
        mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB);
        cv_init(&sc->sc_statecv, "ucomstate");
 
+       rnd_attach_source(&sc->sc_rndsource, device_xname(sc->sc_dev),
+           RND_TYPE_TTY, RND_FLAG_DEFAULT);
+
        SIMPLEQ_INIT(&sc->sc_ibuff_empty);
        SIMPLEQ_INIT(&sc->sc_ibuff_full);
        SIMPLEQ_INIT(&sc->sc_obuff_free);
@@ -361,9 +364,6 @@
        DPRINTF("tty_attach %#jx", (uintptr_t)tp, 0, 0, 0);
        tty_attach(tp);
 
-       rnd_attach_source(&sc->sc_rndsource, device_xname(sc->sc_dev),
-                         RND_TYPE_TTY, RND_FLAG_DEFAULT);
-
        if (!pmf_device_register(self, NULL, NULL))
                aprint_error_dev(self, "couldn't establish power handler\n");
 



Home | Main Index | Thread Index | Old Index