Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb uhidev(9): Assert uhidev is open when writing.



details:   https://anonhg.NetBSD.org/src/rev/b41cd037d784
branches:  trunk
changeset: 364547:b41cd037d784
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Mar 28 12:44:45 2022 +0000

description:
uhidev(9): Assert uhidev is open when writing.

(Maybe we could have uhidevs that are output-only, in which case a
driver could, in principle, want to issue writes without getting any
input report interrupts.  But we can cross that bridge when we come
to it.)

diffstat:

 sys/dev/usb/uhidev.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (42 lines):

diff -r 4d6e10926d8e -r b41cd037d784 sys/dev/usb/uhidev.c
--- a/sys/dev/usb/uhidev.c      Mon Mar 28 12:44:37 2022 +0000
+++ b/sys/dev/usb/uhidev.c      Mon Mar 28 12:44:45 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhidev.c,v 1.92 2022/03/28 12:44:37 riastradh Exp $    */
+/*     $NetBSD: uhidev.c,v 1.93 2022/03/28 12:44:45 riastradh Exp $    */
 
 /*
  * Copyright (c) 2001, 2012 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.92 2022/03/28 12:44:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.93 2022/03/28 12:44:45 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1083,6 +1083,7 @@
 
        mutex_enter(&sc->sc_lock);
        KASSERT(sc->sc_refcnt);
+       KASSERT(scd->sc_state & UHIDEV_OPEN);
        for (;;) {
                if (scd->sc_state & UHIDEV_STOPPED) {
                        err = USBD_CANCELLED;
@@ -1116,6 +1117,7 @@
 
        mutex_enter(&sc->sc_lock);
        KASSERT(sc->sc_refcnt);
+       KASSERT(scd->sc_state & UHIDEV_OPEN);
        KASSERTMSG(sc->sc_writelock == curlwp, "%s: migrated from %p to %p",
            device_xname(sc->sc_dev), curlwp, sc->sc_writelock);
        KASSERTMSG(sc->sc_writereportid == scd->sc_report_id,
@@ -1168,6 +1170,7 @@
 
        mutex_enter(&sc->sc_lock);
        KASSERT(sc->sc_refcnt);
+       KASSERT(scd->sc_state & UHIDEV_OPEN);
        if (scd->sc_state & UHIDEV_STOPPED) {
                err = USBD_CANCELLED;
                goto out;



Home | Main Index | Thread Index | Old Index