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): More attach/detach bugs.
details: https://anonhg.NetBSD.org/src/rev/4958cd2c9d3f
branches: trunk
changeset: 368181:4958cd2c9d3f
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Jun 26 22:49:09 2022 +0000
description:
emdtv(4): More attach/detach bugs.
Reported-by: syzbot+9bbfb743349929e2c8c3%syzkaller.appspotmail.com@localhost
diffstat:
sys/dev/usb/emdtv.c | 11 +++++++----
sys/dev/usb/emdtv_ir.c | 22 ++++++++++++----------
sys/dev/usb/emdtvvar.h | 4 +++-
3 files changed, 22 insertions(+), 15 deletions(-)
diffs (111 lines):
diff -r 3beefae70b3e -r 4958cd2c9d3f sys/dev/usb/emdtv.c
--- a/sys/dev/usb/emdtv.c Sun Jun 26 22:31:58 2022 +0000
+++ b/sys/dev/usb/emdtv.c Sun Jun 26 22:49:09 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emdtv.c,v 1.17 2022/03/29 09:08:44 riastradh Exp $ */
+/* $NetBSD: emdtv.c,v 1.18 2022/06/26 22:49:09 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.17 2022/03/29 09:08:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emdtv.c,v 1.18 2022/06/26 22:49:09 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -148,6 +148,7 @@
emdtv_dtv_attach(sc);
emdtv_ir_attach(sc);
+ sc->sc_subdevs_attached = true;
}
static int
@@ -163,8 +164,10 @@
if (error)
return error;
- emdtv_ir_detach(sc, flags);
- emdtv_dtv_detach(sc, flags);
+ if (sc->sc_subdevs_attached) {
+ emdtv_ir_detach(sc, flags);
+ emdtv_dtv_detach(sc, flags);
+ }
if (sc->sc_iface != NULL) {
status = usbd_set_interface(sc->sc_iface, 0);
diff -r 3beefae70b3e -r 4958cd2c9d3f sys/dev/usb/emdtv_ir.c
--- a/sys/dev/usb/emdtv_ir.c Sun Jun 26 22:31:58 2022 +0000
+++ b/sys/dev/usb/emdtv_ir.c Sun Jun 26 22:49:09 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emdtv_ir.c,v 1.5 2022/03/29 09:08:44 riastradh Exp $ */
+/* $NetBSD: emdtv_ir.c,v 1.6 2022/06/26 22:49:09 riastradh Exp $ */
/*-
* Copyright (c) 2008 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emdtv_ir.c,v 1.5 2022/03/29 09:08:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emdtv_ir.c,v 1.6 2022/06/26 22:49:09 riastradh Exp $");
#include <sys/select.h>
#include <sys/param.h>
@@ -75,10 +75,20 @@
usbd_status status;
int err;
+ mutex_init(&sc->sc_ir_mutex, MUTEX_DEFAULT, IPL_VM);
+
ed = usbd_interface2endpoint_descriptor(sc->sc_iface, 0);
if (ed == NULL)
return;
+ err = workqueue_create(&sc->sc_ir_wq, "emdtvir",
+ emdtv_ir_worker, sc, PRI_NONE, IPL_VM, 0);
+ if (err) {
+ aprint_error_dev(sc->sc_dev, "couldn't create workqueue: %d\n",
+ err);
+ return;
+ }
+
status = usbd_open_pipe_intr(sc->sc_iface, ed->bEndpointAddress,
USBD_EXCLUSIVE_USE, &sc->sc_intr_pipe, sc, &sc->sc_intr_buf, 1,
emdtv_ir_intr, USBD_DEFAULT_INTERVAL);
@@ -88,14 +98,6 @@
return;
}
- mutex_init(&sc->sc_ir_mutex, MUTEX_DEFAULT, IPL_VM);
-
- err = workqueue_create(&sc->sc_ir_wq, "emdtvir",
- emdtv_ir_worker, sc, PRI_NONE, IPL_VM, 0);
- if (err)
- aprint_error_dev(sc->sc_dev, "couldn't create workqueue: %d\n",
- err);
-
ia.ia_type = IR_TYPE_CIR;
ia.ia_methods = &emdtv_ir_methods;
ia.ia_handle = sc;
diff -r 3beefae70b3e -r 4958cd2c9d3f sys/dev/usb/emdtvvar.h
--- a/sys/dev/usb/emdtvvar.h Sun Jun 26 22:31:58 2022 +0000
+++ b/sys/dev/usb/emdtvvar.h Sun Jun 26 22:49:09 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emdtvvar.h,v 1.4 2016/04/23 10:15:31 skrll Exp $ */
+/* $NetBSD: emdtvvar.h,v 1.5 2022/06/26 22:49:09 riastradh Exp $ */
/*-
* Copyright (c) 2008 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -70,6 +70,8 @@
uint16_t sc_vendor, sc_product;
+ bool sc_subdevs_attached;
+
const struct emdtv_board *sc_board;
struct lg3303 *sc_lg3303;
Home |
Main Index |
Thread Index |
Old Index