Module Name: src
Committed By: riastradh
Date: Mon Mar 28 12:44:45 UTC 2022
Modified Files:
src/sys/dev/usb: uhidev.c
Log Message:
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.)
To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/dev/usb/uhidev.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/usb/uhidev.c
diff -u src/sys/dev/usb/uhidev.c:1.92 src/sys/dev/usb/uhidev.c:1.93
--- src/sys/dev/usb/uhidev.c:1.92 Mon Mar 28 12:44:37 2022
+++ src/sys/dev/usb/uhidev.c Mon Mar 28 12:44:45 2022
@@ -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 @@ uhidev_write(struct uhidev *scd, void *d
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 @@ uhidev_write(struct uhidev *scd, void *d
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 @@ uhidev_write_async(struct uhidev *scd, v
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;